For anyone who has the Apress "iPhone Development" book: is it just me, or do they keep overusing @property and @synthesize? For example, for EVERY UI element they declare as an IBOutlet, they also use @property and @synthesize on it. I think this is incorrect. When working with Cocoa on Mac OS, you only use @property for values you're actually going to work with as getters/setters directly:
But man, in this iPhone book, they use @property on EVERY little thing. Just as a test, for the "Control Fun" exercise, I commented out all the @property and @synthesize statements for the UI outlets, and the program still built and ran just fine. So what's with the author's obsession of using @property?
The first apparent misuse of this is on page 34, where the author has a UILabel to show the result of a button press. He declares the IBOutlet, then outside the interface declaration:
This would be appropriate, I think, if he were going to set it DIRECTLY:
But he only calls methods of statusText, e.g. statusText.text = newText.
Can someone clear this up for me? He's basically creating getters & setters (statusText, setStatusText) that are never used, right??
Code:
@property (readwrite, retain) NSString *carName;
...
@synthesize carName;
...
[someObj setCarName:@"Honda"];
But man, in this iPhone book, they use @property on EVERY little thing. Just as a test, for the "Control Fun" exercise, I commented out all the @property and @synthesize statements for the UI outlets, and the program still built and ran just fine. So what's with the author's obsession of using @property?
The first apparent misuse of this is on page 34, where the author has a UILabel to show the result of a button press. He declares the IBOutlet, then outside the interface declaration:
Code:
@property (retain, nonatomic) UILabel *statusText;
This would be appropriate, I think, if he were going to set it DIRECTLY:
Code:
[myView setStatusText:(UILabel *)someOtherLabel];
But he only calls methods of statusText, e.g. statusText.text = newText.
Can someone clear this up for me? He's basically creating getters & setters (statusText, setStatusText) that are never used, right??