码迷,mamicode.com
首页 > 其他好文 > 详细

@property @synthesize如何使用

时间:2014-12-08 21:15:10      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:style   color   使用   sp   on   bs   代码   tt   size   

@property是让编译器自动产生函数申明

  不再写下面2行代码

  -(void) setAge:(int)newAge;

  -(void) age;

  只需要下列一行就可以代替

  @property int age;

 

@synthesize 意思是合成

  @synthesize就是编译器自动实现getter和setter函数

  不用写下列代码

  - (void) setAge:(int)newAge

  {

    age=newAge;

  }

  -(int) age

  {

    return age;

  }

  只需要些

  @synthesize age;

@property @synthesize如何使用

标签:style   color   使用   sp   on   bs   代码   tt   size   

原文地址:http://www.cnblogs.com/penger/p/4151787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!