I make a category like this:
@interface NSObject (defaultSelector)
+(NSString *) defaultSelector;
-(NSString *)defaultSelector;
@end
Then, I used it like this:
-(void)prefetchShortcutWithTable: (Class) someNSManagedObjectClass forInputArray: (NSArray *) inputArray withDictCache: (NSMutableDictionary *) dictToSave
{
NSString * attribute = [someNSManagedObjectClass defaultSelector];
[self prefetchShortcutWithTable:NSStringFromClass(someNSManagedObjectClass) forAttribute:attribute forInputArray:inputArray withDictCache:dictToSave];
}
The whole thing works. However, how does the compiler knows that someNSManagedObjectClass will be a subclass of an NSObject?
In fact, how do I rewrite the function so that -(void)prefetchShortcutWithTable: (Class) someNSManagedObjectClass forInputArray: (NSArray *) inputArray withDictCache: (NSMutableDictionary *) dictToSave only accept subclasses of NSManagedObject?
NSObjectis the base class of anysomeNSManagedObjectClassoranyOtherClassyou are going to make.