Cocoa Tutorial: awakeFromNib vs applicationDidFinishLaunching
When developing an application in Objective-C and using Cocoa, there is a lot of “magic” that happens in the background. As we get more comfortable with the language and the APIs, we begin to discover the source of that magic and understand not only WHY it works but HOW it works.
One of those areas is the initialization and callbacks from the nib files to my code. Normally, when I want a controller to do something after the NIB/XIB has loaded, I add the method -(void)awakeFromNib and know that I will receive a call when all of the connections into the NIB/XIB are complete. But on what object does this get called and how?
Does Objective-C Perform Autoboxing on Primitives?
This article is inaccurate.
The writer was smoking crack or something when he wrote it and has not been able to duplicate his tests since. This article is left here for historical reasons.
One of the things about Objective-C that I find extremely useful is the ability to resolve a method call at runtime. In addition this same functionality allows us to do some fairly creative things with callbacks, passing messages between threads, etc.
However there is a bit of a trick when it comes to passing primitives though some of these methods. For example, one method that I use quite frequently is performSelectorOnMainThread:withObject:waitUntilDone:. How exactly does one pass a BOOL or an int to this method?
(more…)
Cocoa Coding Practice: Old School vs New
This post is in response to a few queries that I have received regarding my last post showing an NSOperation example. One of the questions raised that I will focus on is my -(void)dealloc method in the NSOperation subclass. The questions boiled down to:
Why are you using releases at all. Garbage collection is the future!
and
You should be just doing [self setVar:nil] instead of that [var release], var = nil; crap.