Objective-C语言关键词,与@synthesize配对使用。xcode4.5以及以后的版本,@synthesize可以省略
功能:让
编译器自动编写一个与
数据成员同名的方法声明来省去读写方法的声明。
如:
1、在头文件中:
@property int count;
等效于在头文件中声明2个方法:
- (int)count;
-(void)setCount:(int)newCount;
2、实现文件(.m)中
@synthesize count;
等效于在实现文件(.m)中实现2个方法。
- (int)count
{
return count;
}
-(void)setCount:(int)newCount
{
count = newCount;
}
以上等效的函数部分由
编译器自动帮开发者填充完成,简化了编码输入工作量。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12231606/viewspace-1075728/
,如需转载,请注明出处,否则将追究法律责任。