【问题标题】:Cocoa-Touch. What is the semantic difference between class method init versions alloc/init?可可触感。类方法 init 版本 alloc/init 之间的语义差异是什么?
【发布时间】:2009-12-04 03:29:16
【问题描述】:

有人可以帮我澄清一下这两者之间的语义区别吗:

self.foo = [NSMutableDictionary dictionaryWithCapacity:theCapacity];

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

可以互换吗?如果不是,它们究竟有何不同。

提前致谢。

干杯, 道格

【问题讨论】:

    标签: iphone cocoa-touch nsmutabledictionary


    【解决方案1】:

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

    dictionaryWithCapacity:theCapacity 只是一个捷径

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 2011-07-22
      相关资源
      最近更新 更多