0

Possible Duplicate:
Get an object attributes list in Objective-C

I am trying to find a way to iterate through all properties on an object and assign the first non empty property's value to another variable. All these properties are string and i am trying to use isEqualToString:@"" to check each property manually before assigning the first non empty one to another variable. Is there a way to do this efficiently by iterating through each property instead of having if conditionals checking each property individually?

Community
  • 1
  • 1
John Baum
  • 3,183
  • 11
  • 42
  • 90

1 Answers1

1

Giuseppe's answer is good but it seems you don't need to complicate yourself with that.

If you say all propertys are strings, why not use an NSArray and ,using fast enumeration, check if the string is in the array , if not just add it. That way you don't have a limit (in case you need to modify the project later).

Also this could work even with different types of variables/propertys. When you loop through the array just use isSubclassOfClass: to check type.

skytz
  • 2,201
  • 2
  • 18
  • 23