Objective-C assigning variables question for iphone.

Posted by coder net on Stack Overflow See other posts from Stack Overflow or by coder net
Published on 2010-12-28T15:40:48Z Indexed on 2010/12/28 15:54 UTC
Read the original article Hit count: 422

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c