Objective-C assigning variables question for iphone.
- by coder net
The following piece of code can be written in two ways. I would like to know what are the pros and cons of each. If possible I would like to stick with the one liner.
1)
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]];
self.view.backgroundColor = background;
[background release];
2)
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]];
Any issues with releasing memory etc. with #2? I'm new to Objective-C and would like to follow the best approach.