Tag: cocoa

applicationDidFinishLaunching not running

So I’m starting out with cocoa and ObjC. I’m trying to follow the example in the up and running objective C/cocoa book from oreilly. My applicationDidFinishLaunching doesn’t seem to be getting called. I think it’s a problem with the way I hooked everything up in the IB. Header: http://pastebin.com/6AdQt1uN Class: http://pastebin.com/VCQWJWkj IB: http://img265.imageshack.us/img265/4616/screenshot20110216at111.png Does anyone […]

How to retry a block based URL Request

I am fetching data using iOS7’s new URL request methods, like so: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self.baseUrl stringByAppendingString:path]]]; NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; NSUInteger responseStatusCode = [httpResponse statusCode]; if (responseStatusCode != 200) { // RETRY (??????) } else completionBlock(results[@”result”][symbol]); }]; [dataTask resume]; […]

Bidirectional Map in Cocoa

Cocoa provides NSDictionary, which essentially is an associative array. Is there a nice way to get bidirectional associativity? i.e. one way would have been if NSDictionary had a keyForObject: method which mirrored the behavior of objectForKey:. I don’t really care if NSDictionary is not the way to get this. I know NSDictionary does provide keysOfEntriesPassingTest: […]

Use of @synthesize/@property in Objective-C inheritance

If you have Class A with an instance var “foo” which has a @property/@synthesize directive, and Class B inherits from Class A, does it also need to @property/@synthesize “foo”? The reason I ask is because when I try to use Class B’s “foo”, the calling class says that “foo” is not something of a structured […]

Accessing NSUserDefaults Often

During a logic process in my app, I need to access the user preferences frequently, and a bunch of times 10~15 to determine what needs to be processed and how. May this question is not about performance, but about doing it correctly. Currently I’m doing a [[NSUserDefaults standardUserDefaults] valueForKey:…] each time I need to request […]

adding click action to NSTextField

How do I attach a event to a NSTextField for when I click on it? Are there any examples out there?

What are the angle brackets “<…>” in an Obj-C class interface for?

Can anyone tell me what the angle brackets “<…>” in an Obj-C class interface do? Like this… http://snipt.net/robhawkes/cocoa-class-interface @interface MapMeViewController : UIViewController <CLLocationManagerDelegate, MKReverseGeocoderDelegate, MKMapViewDelegate, UIAlertViewDelegate> { … } From my view they look like some sort of type declaration (considering my previous experience in PHP and JavaScript), like we’re making sure MapMeViewController is a […]

How to determine an array index in Objective C?

I have two arrays in Objective C and I need to find what index something is so I can insert it in the same place. For instance, lets say I have a “name array” and an “age array”. How do I find out what index “charlie” is in the “name array” so I know where […]

How to pase a JSON array in iphone sdk?

I have a login form where the user can login only with the valid memberID and password. If the user enter correct enamel and password i get a result string contains the user information that the user created in the signup process, if it the password is wrong it shows the status 400 as the […]

Auto scrolling to the end of NSTextView

I have a NSTextView on which I am appending console logs. I have implemented this UI in XIB file with scroll views. When my application appends the console logs in the text view, I want the scroll bar to automatically go to the end of the textview. I could not find any property in XIB […]