I have seen examples (on here especially) of calling hideous C functions and getting structures back that have to be iterated, replete with reams of underbars.
Why can’t I do this (pseudo to follow):
Money *cost = [[Money alloc] init];
for (Property *property in [[cost class] properties]){
..
}
for (Method *method in [[cost class] methods]){
..
}
?
Those functions are not hideous. They are all documented in the Objective-C Runtime Reference.
One reason I think there aren’t the
+propertiesand+methodsmethods are because it’s rare you need to look for property/method that you don’t know the name in compile time.The most useful introspection functions in ObjC are
-respondsToSelector:,-isKindOfClass:,-conformsToProtocol:,NSInvocation, KVC, KVO, NSXxxxFromString, and they are operating with objects.