1

I have seen dozens of people using declarations like this in their implementation files:

@interface ViewController ()<UIPickerViewDataSource,UIPickerViewDelegate>

@implementation ViewController
{
  UIPopoverController *popoverController;
      NSString *currentPick;
    ….
}

Is it a good way or shall I define properties in the class extenion like this:

@interface ViewController ()
{
  @property (nonatomic, strong) UIPopoverController *popoverController;
  @property (nonatomic, strong) NSString *currentPick;
    ….
}
@implementation ViewController
@synthesize popoverController;
@synthesize currentPick;
...

I'm a lit a bit confused in this case.

Thanks in advance.

Moonstar
  • 247
  • 1
  • 4
  • 13
  • Yeah sorry coming from Java hearing instace variable confused me, since translating into the terms of objective-c, properties would be the instance variables, in objective-c they are obviously not. The advantages are that defining properties in class extensions is that you can set the getter and/or the setter methods automatically. – Moonstar Apr 16 '14 at 13:56
  • 1
    Related: [Where to put ivars in modern ObjC?](http://stackoverflow.com/q/13566862) – jscs Apr 16 '14 at 18:38

1 Answers1

0

Property vs Instance Variable

The best way is to declare properties within your class extensions.

Community
  • 1
  • 1
Moonstar
  • 247
  • 1
  • 4
  • 13