IOS Variable vs Property
Posted
by
William Smith
on Programmers
See other posts from Programmers
or by William Smith
Published on 2012-07-05T04:43:44Z
Indexed on
2012/07/05
9:22 UTC
Read the original article
Hit count: 272
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;
© Programmers or respective owner