synthesize(合成) keyword in IOS

synthesize creates setter and getter

(从Objective-C 2.0开始,合成可自动生成存取方法)

the setter is used by IOS to set the pointer of the object on storyboard

we uses getter anytime we want to call the object on storyboard and send messages

属性合成的步骤:

1) 在接口部分(也就是头文件)使用@property指令标识属性

    eg: @property int numerator, denominator;

2) 在实现部分使用@synthesize指令

    eg: @synthesize numerator, denominator;

3) 然后在实现部分便可使用该属性进行存取

- (void) print
{
  NSLog(@"%i/%i", numerator, denominator);
}

synthesize(合成) keyword in IOS

上一篇:(转)C# SendMessage 参数与例子


下一篇:SendMessage消息大全及说明