据说下面两个问题都能答对的不到1%

271 篇文章 0 订阅
61 篇文章 0 订阅

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;
}


请问上面代码打印的两个对象地址是否相同?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值