Reputation: 37
I was writing a small code project and I was wondering instead of doing:
@property(readwrite, retain) NSString* make;
@property(readwrite, retain) NSString* model;
@property(readwrite, retain) NSNumber* vin;
If you could declare this all on one line, instead of multiple to have a cleaner code.
Upvotes: 2
Views: 483
Reputation: 7707
You can combine property declarations that are of the same type:
@property (nonatomic, strong) NSString *make, *model;
@property (nonatomic, strong) NSNumber *vin;
One disadvantage to this approach is that you can't use Xcode/Clang's documentation comments feature. For example, this:
/** The model of the car (e.g. Rav4) */
@property (nonatomic, strong) NSString *model;
will generate this documentation in Xcode (as well as in the sidebar and when option-clicking):
If you put them on the same line, they'll get the same documentation comment (so one of them will be wrong).
Upvotes: 4