views:

62

answers:

3

Hi,

I've read apple's Objective-C doc and am curious about using @synthesize. I've seen classes with a long list of @synthesizes and I've seen classes with one @synthesize then a long comma-separated list of ivars. So what's the difference between:

@synthesize ivar1;
@synthesize ivar2;
@synthesize ivar3;

and

@synthesize ivar1, ivar2, ivar3;

????

+2  A: 

Programmer preference. They're functionally equivalent.

BJ Homer
+6  A: 

It's purely a style choice, just like there's no difference between

int x, y, x;

and

int x;
int y;
int z;
dancavallaro
+1  A: 

Like others have said, it's a matter of preference. But if you're using version control (like any developer should), it can be helpful to have them each on their own line so that file differences are more clear, especially for systems that track the history of each line.

Jeff Kelley
I agree to this, although I sometimes combine very closely tied properties in a single @synthesize.
zenzelezz