Day.01.18 Foundation 对象间的关系

        NSObject *object1 = [[NSObject alloc]init];
        
        NSObject *object2 = [[NSObject alloc]init];
        
        //1.判断地址
        NSLog(@"两个对象%@",(object1 == object2)?@"相同":@"不相同");
        
        //2.比较对象
        BOOL isEqual = [object1 isEqual:object2];
        
        NSLog(@"两个对象%@",isEqual?@"相同":@"不相同");
        
        //3.比较字符串
        NSString *string1 = @"hello";
        
        NSString *string2 = @"hello";
        
        NSLog(@"%p %p",string1,string2);
        
        BOOL isEqualString = [string1 isEqualToString:string2];
        
        NSLog(@"两个字符串的内容%@",isEqualString?@"相同":@"不相同");

2016-01-18 19:12:43.994 Foundation 对象与类的关系[3871:600077] 两个对象不相同
2016-01-18 19:12:43.995 Foundation 对象与类的关系[3871:600077] 两个对象不相同
2016-01-18 19:12:43.995 Foundation 对象与类的关系[3871:600077] 0x1000042c8 0x1000042c8
2016-01-18 19:12:43.995 Foundation 对象与类的关系[3871:600077] 两个字符串的内容相同
Program ended with exit code: 0

你可能感兴趣的:(Day.01.18 Foundation 对象间的关系)