1. Please confirm if I understand this correctly.

I have a line of code below,

@property (strong, nonatomic) Month *august; and it will setup below.

1 setter -(void)setAugust:(Month *)august

1 getter -(Month *)august

and 1 ivar _august

and when I implement my own setter, I have to _august = august (inside of setter to assign the ivar with proper value)

2. Another question, some example shows: when I implement setter , they use _ivar = ivar; and others use @synthesize _ivar = ivar;.

I believe @synthesize was used to create setter and getter but it's abbreviated as of iOS 6, right? I am confused of using the statement while implementing setter.

3. @property (nonatomic, getter=isPlan) BOOL plan;

What does "getter=" exactly mean?

有帮助吗?

解决方案

  1. You are correct (after the 2 typos I corrected - if they weren't typos make sure you understand the difference).
  2. @synthesize used to be required but isn't any more. This is a feature of Xcode (the compiler really), not any version of iOS.
  3. It generates the getter method with a different signature:

Normal:

- (BOOL)plan;

Specified:

- (BOOL)isPlan;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top