1

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;
anny123
  • 5,060
  • 11
  • 50
  • 95
  • Does this answer your question? [Property vs Instance Variable](https://stackoverflow.com/questions/7057934/property-vs-instance-variable) – Alexander Jun 10 '21 at 05:08

1 Answers1

2

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.

Alexander
  • 54,014
  • 10
  • 87
  • 136