purpose of @property in objective c

后端 未结 3 1904
盖世英雄少女心
盖世英雄少女心 2021-01-28 20:09

Look a the below code;

@interface testViewController : UIViewController
{
     int age;
     UIPopoverController *popoverController;
}
@property (nonatomic , ret         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-28 20:54

    If you have this:

    @property (nonatomic , retain ) UIPopoverController *popoverController;
    

    the methods generated by @synthesize will be something like:

    -(UIPopoverController*) popoverController
    {
        return popoverController;
    }
    
    -(void) setPopoverController: (UIPopoverController*) newValue
    {
        [newValue retain];
        [popoverController release];
        popoverController = newValue;
    }
    

提交回复
热议问题