iPhone memory management, a newbie question

Posted by Reuven on Stack Overflow See other posts from Stack Overflow or by Reuven
Published on 2010-04-26T13:37:43Z Indexed on 2010/04/26 13:43 UTC
Read the original article Hit count: 213

Filed under:
|

Hi,

I've seen in (Apple) sample code two types of ways of allocation memory, and am not sure I understand the difference and resulting behavior.

// FAILS
NSMutableArray *anArray = [NSMutableArray array];
[anArray release];

// WORKS
NSMutableArray *anArray1 = [[NSMutableArray alloc] init];
[anArray release];

By "FAILS" I mean I get crashes/runtime warnings etc., and not always as soon as I call the release...

Any explanation appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-management