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 ?
@propertyand@synthesize(and@dynamic) keywords were added in the 2.0 version of the language specification. if you're an apple developer, their Objective-C Language reference is useful knowledge@interfaceblock); the second creates it via@synthesize. The question I linked may not be an exact exact duplicate, but the answer to your question is there, and there are a number of other questions linked from it that also cover this.