'Does Objective-C's @synthesize need to be done for each type?

I have a whole load of @synthesize lines at the top of my obj-c file.

Right now I'm doing @synthesize for each type of variable, so if I have two ints called xx, yy then I use @synthesize for them both, etc., but I've still got lots of lines of @synthesize.

Do I need to do that?

Or can I just stick everything on one big @synthesize line?



Solution 1:[1]

Both are fine. This is your style.

@synthesize a,b,c; 

is similar to

@synthesize a;
@synthesize b;
@synthesize c;

One line containing one synthesize gives you readability.

If you put dozens of synthesize in one line, and you get some error, you need to scan again for all the synthesize names.

While multiple line synthesize will show you the error and easy to debug.

** Also XCode4.4+ running with new compiler gives you auto-synthesize, so no need to synthesize at all.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1