【发布时间】:2012-06-30 15:46:11
【问题描述】:
我对@987654323@ 和[[Class alloc] init] 有点困惑。我使用[Class new] 和[[Class alloc] init] 定义了一个对象content。
(1). NSMutableArray *content = [NSMutableArray new];
(2). NSMutableArray *content = [[NSMutableArray alloc] init];
我的问题是关于[Class new] 和[[Class alloc] init] 之间的区别。对我来说,(1)和(2)是相似的。如果 (1) 和 (2) 相似,那么为什么我们大部分时间都使用[[Class alloc] init],而不是[Class new]?我认为应该有一些不同。
请解释一下两者的区别、优缺点?
【问题讨论】:
标签: ios objective-c new-operator allocation init