【发布时间】:2010-08-14 19:08:31
【问题描述】:
3 个相关问题:
1.下面的代码sn-ps是否在内存方面提供了完全相同的结果?
NSBundle *bundle=[[NSBundle alloc] init];
[bundle release];
bundle=nil;
和
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSBundle *bundle=[NSBundle mainBundle];
[pool drain];
pool=nil;
bundle=nil;
2.为什么在
NSBundle *bundle=[[NSBundle alloc] init];
[bundle release];
bundle的retainCount是1,不是0?
3.推荐哪种方式:始终使用类方法,还是始终使用alloc获得所有权?
谢谢。
【问题讨论】:
标签: objective-c xcode memory