iOS

@synthesize

2017-05-09  本文已影响7人  码农二哥

Most Properties Are Backed by Instance Variables

You Can Customize Synthesized Instance Variable Names

@implementation YourClass
@synthesize propertyName = instanceVariableName;
...
@end

For example:@synthesize firstName = ivar_firstName;

In this case, the property will still be called firstName, and be accessible through firstName and setFirstName: accessor methods or dot syntax, but it will be backed by an instance variable called ivar_firstName.

Important: If you use @synthesize without specifying an instance variable name, like this:

@synthesize firstName;

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW2

上一篇 下一篇

猜你喜欢

热点阅读