Question1:
@interface Rectangle : NSObject
@property (nonatomic, copy) NSMutableString *name;
@end
@implementation Rectangle
- (void)setName:(NSMutableString *)name {
_name = name;
}
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Rectangle *object = [[Rectangle alloc] init];
NSMutableString *mStr = [NSMutableString stringWithFormat:@"Hello, world"];
object.name = mStr;
NSLog (@"mStr: %p object.name: %p", mStr, object.name);
return YES;
}
请问上面代码打印的两个对象地址是否相同?
Question2:
@interface Rectangle : NSObject
@property (nonatomic, copy) NSString *name;
@end
@implementation Rectangle
- (void)setName:(NSString *)name {
_name = [name copy]
}
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Rectangle *object = [[Rectangle alloc] init];
NSString *mStr = [NSString stringWithFormat:@"Hello, world"];
object.name = mStr;
NSLog (@"mStr: %p object.name: %p", mStr, object.name);
return YES;
}
请问上面代码打印的两个对象地址是否相同?