Difference between self.ivar and ivar?

后端 未结 4 1042
遇见更好的自我
遇见更好的自我 2020-11-22 12:11
aclass.h

@interface aClass : NSObject {
    NSString *name;
}

@property (nonatomic, retain) IBOutlet NSString *name;

@end

aclass.m         


        
4条回答
  •  清酒与你
    2020-11-22 12:55

    It's real a memory management, firt the property grammar is real setter and getter method, when use self.xxx = ?, it could call setter method, the object retain cout +1, name can not be release, however if name = foo is nothing about property grammar.

    setter method example:

    -(void)setObj:(ClassX*) value 
    {  
             if (obj != value) 
             { 
                       [obj release]; 
                       obj = [value retain]; 
             } 
    } 
    

提交回复
热议问题