可能重复:
what is difference between alloc and allocWithZone:?Objective-C - alloc和allocFromZone之间的区别?
我读到提及使用allocWithZone
的文章有助于通过使用一个内存位置更接近对象本身提高性能。这是真的?是否推荐使用allocWithZone
而不是alloc
? alloc和allocWithZone有什么区别?
proveded的例子是:
- (id)init
{
if (self = [super init])
{
_myString = [[NSString allocWithZone:[self zone] init]];
}
return self;
}