我读过一篇文章,其中提到 usingallocWithZone
通过使用更靠近对象本身的内存位置来帮助提高性能。这是真的?是否建议使用allocWithZone
而不是alloc
?alloc 和 allocWithZone 有什么区别?
证明的例子是:
- (id)init
{
if (self = [super init])
{
_myString = [[NSString allocWithZone:[self zone] init]];
}
return self;
}