Reputation: 38180
In most tutorials, the way to declare instance variable is to put it in .h
@interface myViewController: UIViewController {
UITextField *myTextField;
}
@property (nonatomic, retain) IBOutlet UITextField *myTextField;
and in .m
@implementation myViewController
@synthetize myTextField;
But in this standford University course http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id480479762 the way to do so is rather
In .h do only:
@interface myViewController: UIViewController
@property (nonatomic, retain) IBOutlet UITextField *myTextField;
In .m do this:
@synthetize myTextField = _myTextField;
Are they equivalent ? Is the second method specific to iOS5 ?
Upvotes: 0
Views: 188
Reputation: 1206
diffrence exist, in first variant you can see value of param in debugger in second variant you can't see value of param in debug mode
Upvotes: 1
Reputation: 80603
They are functionally equivalent. In ObjC 2.0 the synthesize
keyword will automatically create the associated ivar if you do not specify one as part of the synthesize
statement. This functionality is present on all modern runtimes.
Upvotes: 2
Reputation: 10104
They both work the same way, in the last one you actually have an instance variable named _myTextField. I don't know when this "feature" started, and would be interesting to know if the variable is inserted by the compiler or pre-compiler...
Upvotes: 1