【iOS】copy和mutableCopy

2015-12-02  本文已影响0人  cod_mm

NSString

NSString *str = @"copy and mutableCopy";
NSLog(@"NSString: %@ %p", NSStringFromClass([str class]), str);

NSString *copyStr = [str copy];
NSLog(@"NSString copy: %@ %p", NSStringFromClass([copyStr class]), copyStr);

NSMutableString *mutableCopyStr = [str mutableCopy];
NSLog(@"NSString mutableCopy: %@: %p", NSStringFromClass([mutableCopyStr class]), mutableCopyStr);

NSMutableString

NSMutableString *str0 = [@"test" mutableCopy];
NSLog(@"NSMutableString: %@: %p", NSStringFromClass([str0 class]), str0);

NSMutableString *str1 = [str0 copy];
NSLog(@"NSMutableString copy: %@: %p", NSStringFromClass([str1 class]), str1);

NSMutableString *str2 = [str0 mutableCopy];
NSLog(@"NSMutableString mutableCopy: %@: %p", NSStringFromClass([str2 class]), str2);
上一篇下一篇

猜你喜欢

热点阅读