-5

Possible Duplicate:
Property vs. instance variable

Can someone tell me what is the difference between:

@interface SplitApp6DetailViewController : UIViewController <UISplitViewControllerDelegate, MKMapViewDelegate>{
sqlite3         *databaseHandle;
}

and

@interface SplitApp6DetailViewController : UIViewController <UISplitViewControllerDelegate, MKMapViewDelegate>
@property (nonatomic) sqlite3* databaseHandle;

I am confused with these 2 approaches.

Thanks!

Community
  • 1
  • 1
Yashu
  • 485
  • 1
  • 10
  • 22
  • 4
    this has been answered many times: http://stackoverflow.com/questions/719788/property-vs-instance-variable – wattson12 Aug 14 '12 at 09:01

2 Answers2

0

You can use the @property approach in conjunction with @synthesize to automatically generate getters and setters.

That is the new way of doing things, it makes working with getters/setters a lot easier because you don't have to write them yourself. The instance variable (which is defined between the braces, like in your example above) is also created for you, so there is no need to do this manually unless you want to support older versions of the system.

More information here

Asciiom
  • 9,867
  • 7
  • 38
  • 57
  • so normally(and easier) we use /@property and /@synthesize other than the other way? – Yashu Aug 14 '12 at 09:09
  • That is the new way of doing things, it makes working with getters/setters a lot easier because you don't have to write them yourself. The instance variable (which is defined between the braces, see your example above) is also created for you, so there is no need to do this manually unless you want to support older versions of the system. – Asciiom Aug 14 '12 at 09:23
0

One is declaring a class with an instance variable, the second is declaring a class with a property.

Stig Brautaset
  • 2,602
  • 1
  • 22
  • 39