I often have custom classes in Objective C, such as a contact-class containing name, phone number, e-mail and so on, looking for instance like this:
NSString *firstName;
NSString *familyName;
NSString *emailAddress;
...
In order to put these values into an array, I have to do this:
if (firstName) [someArray addObject:firstName];
if (familyName) [someArray addObject:familyName];
if (emailAddress) [someArray addObject:emailAddress];
...
Is there a way to do something more like:
for (not nil objects) {
[someArray addObject:firstName];
[someArray addObject:familyName];
[someArray addObject:emailAddress];
...
}
where every line containing a nil object is ignored?