I was looking at some sample code on a Jeff LaMarche excellent blog when I came across the following:
- (void) applicationDidFinishLaunching: (UIApplication *) application
{
CGRect rect = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: rect];
GLViewController * theController = [[GLViewController alloc] init];
self.controller = theController;
[theController release];
// ...
}
In .h we see that the โwindowโ and โcontrollerโ are Ivars declared like this:
@interface OpenGLTestAppDelegate: NSObject
{
UIWindow * window;
GLViewController * controller;
}
@property (nonatomic, retain) IBOutlet UIWindow * window;
@property (nonatomic, retain) IBOutlet GLViewController * controller;
@end
My question is: why are the "window" and the "controller" assigned differently?
I think I understand why each type of task works (tracking the number of deductions), but why are they assigned differently? In particular, why the controller is not assigned in the same way as a window with the same line without going through the setter:
controller = [[GLViewController alloc] init];
In general, when will you use the single line method and when will you use the multiple line method?
Thanks.
source
share