0

I was just wondering if I could do some thing like for (id something in someArray) for properties. For instance, I declared a bunch of properties for a class A and two objects A,B of this class. I want to go through each one of the properties of object A and compare them with those of other object B. Is there a fast way like fast enum that I can use?

Haoyu
  • 49
  • 1
  • 7
  • Take a look at `class_copyPropertyList` function of Objective-C runtime. – iHunter Aug 28 '13 at 06:31
  • @CarlVeazey Thanks a lot for the comments. I was not clear when I mentioned objects A and B. They are of the same class, so the property names are the same. I want to compare the actual values of those properties. When I looked at the document, it seems to me the property list generates only include the property names, not the values. – Haoyu Aug 28 '13 at 06:50
  • @iHunter, thanks for your comment as well. I guess I need a little more help as I clarified in my comment above. – Haoyu Aug 28 '13 at 06:51
  • Understood. In some (many?) cases you can use KVC to get the value of the property and compare it that way. The general, works-for-anything case is going to be tough, because there are so many cases to consider, and then situations like `UIView` for instance where its property list has far fewer properties than are defined in its header. If you are just looking for a quick way to implement `isEqualTo<#CLASSNAME#>:` in a single class, there are easier ways, in my view, that may require occasional maintenance but are easy to read and write. – Carl Veazey Aug 28 '13 at 07:23

0 Answers0