我仍然試圖圍繞iphone內存管理。我已經檢查了這個漏洞,但我想確保。這是沒有泄漏?iphone內存管理和陣列
NSMutableArray *array = [[NSMUtableArray alloc] init];
NSMutableString *str = [[NSMutableString alloc]];
[str appendstring:@"hi"];
[array addObject:str];
[str release]; //this is the bit I am most concerned about
...some processing of array occurs...
[array release];
可能沒有泄漏,但它不」編譯。 :) –
缺少第2行的'init'?無論如何,似乎是無泄漏的。 – Ryan
我的書中關於這個主題的章節可以免費在線獲得:http://www.apeth.com/iOSBook/ch12.html#_memory_management(當然,所有這些都會被重寫,以考慮到ARC) – matt