IOS Variable vs Property
- by William Smith
Just started diving into Objective-C and IOS development and was wondering when and the correct location I should be declaring variables/properties. The main piece of code i need explaining is below:
Why and when should i be declaring variables inside the interface statement and why do they have the same variable with _ and then the same one as a property. And then in the implementation they do @synthesize tableView = _tableView (I understand what synthesize does)
Thanks :-)
@interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
UITableView *_tableView;
UIActivityIndicatorView *_activityIndicatorView;
NSArray *_movies;
}
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, retain) NSArray *movies;