I have a question about initializing NSMutableString for objective-c.
NSMutableString*ms1 = NSMutableString string;
NSMutableString* ms2 = [[NSMutableString alloc] init];
NSMutableString* ms3 = [NSMutableString new];
Yes.
So I have a question.
·What is the ideal initialization method for objective-c?
·Also, why is the initialization method good?
That's all, thank you.
ios objective-c
Any environment where ARC is enabled is the same.There is no change or difference.
The method new
is a shortened form of alloc
+ init
, so-called "Syntax Sugar".
There was a difference between alloc
+ init
and string
where alloc
+ init
+ autorelease
is an abbreviated format.
© 2024 OneMinuteCode. All rights reserved.