What is the difference between
@property (nonatomic, retain) NSString *subject, *name, *kind;
and
@property (nonatomic, retain) NSString *subject;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *kind;
I think the functionality is exactly the same but the first one only saves you typing and some lines of code. I am not sure though that is why I am asking 🙂
and
Both the way are same.
But I prefer later one. Reason??
If you have any typo or whatever bug, you will be pointed by compiler in exact the line having that property/variable name.
If I write dozens of property and/or variable then I have to look for each of them, which one is root cause for error…. As I used @synthesize for quite a time, it was too difficult to find.
So I always advised and guided others to make one line declaration of variables, properties, synthesize etc.
I am lazy. Few think why to write same thing multiple times? Extra time and work.
But multiple lines will be more readable. You code just once and it is read hundreds of times, so just few seconds to type some extra keywords. And thanks to all the IDEs that provide you autocomplete so nowadays this reason is nearly obsolete.
EDIT:
As per vikingosegundo comment,
you should never use
retainfor NSString, usecopy.For Immutable objects
copyshould be used notretain.