[[MyObject class] respondsToSelector:...] asks if the meta object is responding to this selector. So, in reality, he asks if a class method exists with this selector. Your code will return YES if you have:
+ (NSString *)myProperty;
It returns NO because you have the equivalent of an instance method:
- (NSString *)myProperty;
You need to call respondsToSelector: on an instance of your class.
You can usually use instancesRespondToSelector: directly in the metaclass (so [MyObject instancesRespondToSelector:...] ), but Core Data only synthesizes the corresponding method implementations when creating an object, so it does not start. However, you could create an instance using the regular NSEntityDescription route and respondsToSelector: test.
Since everything is Core Data, an alternative would be to set the NSManagedObjectModel for the corresponding NSEntityDescription through its entitiesByName dictionary and check the propertiesByName description dictionary.
Tommy source share