Alwaysblue
Alwaysblue

Reputation: 11930

Difference between declaring properties in interface

Can someone tell me what is the difference between declaring a property in interface like this

@interface RootViewController : UITableViewController {
  NSDate *timestamp;
}
@end

and

@interface RootViewController : UITableViewController 
@property (nonatomic, retain) NSDate *timestamp;
@end

and

@interface RootViewController : UITableViewController {
  NSDate *timestamp;
}
@property (nonatomic, retain) NSDate *timestamp;

Upvotes: 1

Views: 41

Answers (1)

Alexander
Alexander

Reputation: 63369

The former is not a property at all. It's an instance variable declaration.

The latter is a property, which is a term for a getter/setter pair and their backing instance variable.

The instance variable that's synthesized for you will be prefixed with _. So if you look at RootViewController using the Objective C runtime APIs, you can see it actually has an ivar named _timestamp.

Upvotes: 2

Related Questions