Objective-C retain clarification

Posted by Maverick on Stack Overflow See other posts from Stack Overflow or by Maverick
Published on 2010-09-20T14:58:28Z Indexed on 2011/01/07 11:54 UTC
Read the original article Hit count: 158

Filed under:
|
|

I'm looking at this code:

NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < kNumberOfPages; i++) {
    [controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
[controllers release];

Later on...

- (void)dealloc {
    [viewControllers release];
    ...
}

I see that self.viewControllers and controllers now point to the same allocated memory (of type NSMutableArray *), but when I call [controllers release] isn't self.viewControllers released as well, or is setting self.viewControllers = controllers automatically retains that memory?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c