可可触摸。类方法init版本alloc / init之间的语义差异是什么?

时间:2009-12-04 03:29:16

标签: iphone cocoa-touch nsmutabledictionary

有人可以请我澄清这两者之间的语义差异:

self.foo = [NSMutableDictionary dictionaryWithCapacity:theCapacity];

self.foo = [[[NSMutableDictionary alloc] initWithCapacity:theCapacity] autorelease];

是可互换的吗?如果不是,他们究竟有多么不同。

提前致谢。

干杯, 道格

1 个答案:

答案 0 :(得分:3)

在这种情况下,它们完全可以互换。

dictionaryWithCapacity:theCapacity只是一个快捷方式