Example 1:
@property (nonatomic, strong)NSString *fname;
In your .h file you declare a property as what you see above code. Then to call that in .m file, your getters and setters become:
Setters - isFname;
Getters - fname;
Example 2:
@property (nonatomic, getter = getBal, setter = setBal:)double balance;
In this example you are setting name of your getters and setters variable. In your .m file your getters and setters become:
Setters - setBal;
Getters - getBal;
Note:
Don't forget the code below implementing to get the value of the variable.
@synthesize fname, balance;
Based on my understanding, that's all I got learned about setters and getters in IOS Programming.
No comments:
Post a Comment