简体   繁体   中英

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

is memory allocated in [[UIImageView new] init] as well ?

+ new is equivalent with + alloc followed by - init , so

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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