简体   繁体   English

[[UIImageView new] init]和[[UIImageView alloc] init]之间的区别

[英]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.

相关问题 时间分析器:优化UIImageView分配/初始化调用 - Time Profiler: Optimizing UIImageView alloc/init calls [[CAShapeLayer alloc] init]和[CAShapeLayer层]之间的区别 - Difference Between [[CAShapeLayer alloc] init] and [CAShapeLayer layer] [NSMutableData数据]和[[NSMutableData alloc] init]之间的区别 - Difference between [NSMutableData data] and [[NSMutableData alloc]init] [NSMutableArray数组]与[[NSMutableArray alloc] init]之间的区别 - Difference between [NSMutableArray array] vs [[NSMutableArray alloc] init] [[NSDate date] retain]和[[NSDate alloc] init]之间的区别 - Difference between [[NSDate date] retain] and [[NSDate alloc] init] 可可接触。 类方法初始化版本alloc / init之间的语义区别是什么? - Cocoa-Touch. What is the semantic difference between class method init versions alloc/init? UIImageView和drawInRect有什么区别? - what is the difference between UIImageView and drawInRect? UIImageView * XXX = [[UIImageView分配] initWithImage:XXX] - UIImageView* XXX = [[UIImageView alloc] initWithImage:XXX] 在 iPhone UIImageView 中,用什么方法来覆盖实例变量 init? - In iPhone UIImageView, what method to override for instance variable init? 如何在init方法中更改nib uiimageview图像? - How to change the nib uiimageview image inside init method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM