[英]Difference between [[UIImageView new] init] and [[UIImageView alloc] init]
I am just wonder what is the difference between [[UIImageView new] init] and [[UIImageView alloc] init] . 我只是想知道[[UIImageView new] init]和[[UIImageView alloc] init]之间有什么区别。
is memory allocated in [[UIImageView new] init] as well ? 在[[UIImageView new] init]中也分配了内存吗?
+ new
is equivalent with + alloc
followed by - init
, so + new
相当于用+ alloc
由跟随- init
,所以
UIImageView *iv = [[UIImageView alloc] init];
and 和
UIImageView *iv = [UIImageView new];
are right (and equivalent) and 是正确的(和等效的)并且
UIImageView *iv = [[UIImageView new] init];
is wrong, since it calls - init
twice. 是错误的,因为它调用
- init
两次- init
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.