FAQ Database Discussion Community


NSObject as delegate for UITableView

objective-c,uitableview,nsobject
I have a UITableView which is dragged into a UIViewController and a NSObject class. This NSObject class should serve as delegate and datasource to the tableview. I tried creating an instance of NSObject and conformed delegate and datasource to the tableview. Datasource is working fine. But the cellForRowAtIndexPath: is never...

ios subclassing error casting subclass

objective-c,subclass,nsobject
I have a Widget class of nsobject with some properties and some methods, then I have a Widget subclass called Gallery, this class has some method and some properties... When I fetch data from web I save all data into Widget object, if one of this obj has a specific...

Applying Generics to Variables and Functions - Swift

ios,generics,swift,protocols,nsobject
I'm trying to use generics in swift in order to initialise variables within my Vector3D class. However, upon assigning the protocol 'Number' to my variable (to make it either a Double or Float) I get the following error: Protocol 'Number' can only be used as a generic constraint because it...

iOS: create an object class with Swift

ios,oop,swift,nsobject
I created this class for my object City class City: NSObject { var _name:String = "" var name:String { get { return _name } set (newVal) { _name = newVal } } } then when I crate my object I do: var city:City! city.name = "London" //crash here println("name city...

Extend a ViewController inside a container view in a scroll view

objective-c,nsobject
Essentially what I have is a view controller full of auto-resizing UILabels and what I am wanting to do is to have it resize the view so it will allow me to scroll through all of the text labels without cutting them off. It shows the first three fine but...

How to iterate concisely through @properties on an NSObject subclass to set properties from a plist?

cocoa,nsarray,nsdictionary,plist,nsobject
Say I have a subclass of NSObject (let's call it 'BSObject') with the following properties: NSString *name; NSNumber *num; I have an NSMutableArray of BSObjects (let's call that one 'BSCollection'). For storage on disk, I have a property list which is an array of dictionaries. The BSCollection is represented by...

iOS - Locally saving an array of key value pairs

ios,swift,nsobject,nscoder
In an app I'm developing the user needs to add an "enterprise" to use the app. However, they can add more than one "enterprise" to the app. Every enterprise added needs two things: a name, and an enterprise API key. I have created an "Enterprise" class: class Enterprise : NSObject...

How do I figure out when the contents of NSData indicate that a webservice request has failed?

ios,objective-c,web-services,cocoa-touch,nsobject
I'm trying to persist data from a microsoft web service call to a file when my app starts up. If the app is able to complete the webservice request, it's storing the data in an NSData object. Assuming the data has been successfully requested and stored, I want to execute...

'Xcode cannot find protocol declaration of “UIViewControllerAnimatedTransitioning”'

delegates,xcode6,nsobject
I created a vanilla Xcode (v6.2) project (Project A) that throws the error: 'Xcode cannot find protocol declaration of "UIViewControllerAnimatedTransitioning"' Here's the code: #import <Foundation/Foundation.h> @interface WTF : NSObject <UIViewControllerAnimatedTransitioning> @end Weird thing is, I have a example project that I downloaded (Project B) that I can put the exact...

iOS: setter in an object class with external parameter

ios,oop,swift,nsobject
I have this object class class City { var name:String init(name: String) { self.name = name } var video:String? var description:String? var image_array:NSArray? } in this class there is a property called image_array, and I want to assign it an NSArray as you can read. But in this case I...

Set NSObject property - EXC_BAD_ACCESS

ios,objective-c,exc-bad-access,nsobject
Process : App is on the home view controller and is requesting data on API to set an NSObject property. The request is processing on a private method. User change the view controller to a second view controller (the request is still processing asynchronously) The second view controller is loaded...

Call method after asynchronous request obj-c

ios,objective-c,asynchronous,uiviewcontroller,nsobject
In my app I init a new object, where there is method which calls NSURLConnection's sendAsynchronousRequest method. After the request, I would like to call a method in the caller UIViewController. I tried to use a static method but I then I can't control IBOutlets. How can I do this?...

How to create a Swift object in Objective-C?

objective-c,swift,nsobject
If you define a swift class like this @objc class Cat { } In swift you can just do var c = Cat() But how do you make a Cat instance in Objective-C ? Subclassing NSObject works because you can then "alloc-init" but can we achieve this without subclassing an...

How do you store big objects using NSUserDefaults efficiently? [closed]

objective-c,nsuserdefaults,nsobject
How do you store big objects using NSUserDefaults efficiently? Any help will be appreciated. Thanks!

How do I create a private global variable in an NSObject class?

ios,objective-c,nsobject
I want to create a private global variable in an NSObject class. Here is what I have so far: + (MyClass *)sharedInstance { static MyClass *sharedInstance; static dispatch_once_t once; dispatch_once(&once, ^{ sharedInstance = [[self alloc] init]; }); return sharedInstance; } I want to create and assign an NSDictionary that can...

add “Load More” to tableview NSObject json parse

swift,uitableview,nsobject
hi i have blog application parser from json object its work well , i want add ''load more' for table view but I got this error in this line appDataArray.addObjectsFromArray(allObjectArray.subarrayWithRange(NSMakeRange(currentPage, 20))) the error http://i.imgur.com/BLGXysR.png this object code var title: String var image: String var web: String var catname: String var...

Extract value from NSObject key/value pair

objective-c,xcode,nsobject
I have a NSObject variable which represents something like : {objectID : 2, name : John Doe, url : www.test.com } I want to extract only the url from the NSObject variable. How can I do that?...

NsArray ContainsObject is not working with Custom NsObject Class

ios,objective-c,compare,nsarray,nsobject
I am checking if my one of the array consist the Nsobject which i have created custom way. i am using ContainsObject method.my problem is that contains object not working ever.even though i have same object in array its not returning the true value. if([self.arrSelectedInterest containsObject:interest_ent]) i am also attaching...

Why doesn't Swift force my designated initializer to call super?

swift,initialization,nsobject
This code is legal in Swift: class Snapper : NSObject { var anim : UIDynamicAnimator init(referenceView:UIView) { self.anim = UIDynamicAnimator(referenceView:referenceView) // super.init() } } Observe that in my initializer I didn't call super.init(); I commented out that line. But the Swift compiler doesn't complain. Why? I thought there was a...

How to observe an array of NSObjects in swift?

arrays,swift,nsobject,observable,observers
I am new in swift language and my problem is about how to use observable/observer pattern in swift. I want to make my array to be observable in my SocketManager class so it can be observed by my UIViewController class. I have used the Observable class written by Andrew J...

How to Sort object by alphabet order for UITableViewCell?

ios,objective-c,uitableview,nsmutablearray,nsobject
I want to sort objects that i created & stored in NSMutableArray in AppDelegate.m. Stations is NSObject Class I want to show station names in another UIViewController in alphabet order(in UITableViewCell) & when i click on them i want to pass the object that contains station name,latitude,longitude to next UIViewController...