Declaration of variables in the class extension (anonymous category) vs Implementation [duplicate]

StackOverflow https://stackoverflow.com/questions/23110947

Pregunta

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.

¿Fue útil?

Solución

Property vs Instance Variable

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top