Tuesday, October 05, 2010

iPhone development: Objective C

hmm.. property has to be defined after interface

eg.:

@interface MyViewController : UIViewController {
UITextField *textField;
UILabel *label;
NSString *string;
}
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *string;

- (IBAction) changeGreeting: (id) sender;


NOT

@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *string;

- (IBAction) changeGreeting: (id) sender;
@interface MyViewController : UIViewController {
UITextField *textField;
UILabel *label;
NSString *string;
}


to use these in the .m files
must use @synthesize
eg.:
@synthesize textField;
@synthesize label;
@synthesize string;

No comments: