简体   繁体   English

可可接触。 类方法初始化版本alloc / init之间的语义区别是什么?

[英]Cocoa-Touch. What is the semantic difference between class method init versions alloc/init?

Could someone please clarify for me the semantic difference between these two: 有人可以帮我澄清一下两者之间的语义区别:

self.foo = [NSMutableDictionary dictionaryWithCapacity:theCapacity]; self.foo = [NSMutableDictionary dictionaryWithCapacity:theCapacity];

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

Are the interchangable? 可以互换吗? If not how exactly do they differ. 如果不是,它们到底有什么不同。

Thanks in advance. 提前致谢。

Cheers, Doug 干杯,道格

In this case they are totally interchangeable. 在这种情况下,它们是完全可以互换的。

dictionaryWithCapacity:theCapacity is just a shortcut dictionaryWithCapacity:theCapacity只是一个捷径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM