Questions tagged «nsautoreleasepool»

7
NSAutoreleasePool自动释放池如何工作?
据我了解,使用alloc,new或copy创建的任何内容都需要手动释放。例如: int main(void) { NSString *string; string = [[NSString alloc] init]; /* use the string */ [string release]; } 我的问题是,这样难道不是同样有效吗?: int main(void) { NSAutoreleasePool *pool; pool = [[NSAutoreleasePool alloc] init]; NSString *string; string = [[[NSString alloc] init] autorelease]; /* use the string */ [pool drain]; }

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.