I\'m trying to upgrade my app with Xcode5 but encountered a number of \'Semantic issues\' in a third party library (being MagicalRecord). The quickest way to \'fix\' this mi
Yes you should.
instead of doing this:
[self.searchResults sortUsingSelector:@selector(compareByDeliveryTime:)];
you should do this:
SEL compareByDeliveryTimeSelector = sel_registerName("compareByDeliveryTime:");
[self.searchResults sortUsingSelector:compareByDeliveryTimeSelector];
These selector warnings in MagicalRecord are for compatibility with mogenerator's generated Core Data classes. Besides using mogenerator and perhaps importing one of the entities there really isn't much you can do besides what was already answered.
Another option of course is to surround that code specifically with ignore blocks
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
and at the end
#pragma clang diagnostic pop
You just need to declare a class or protocol that contains the selector. For example:
// DeliveryTimeComparison.h
#import <Foundation/Foundation.h>
@protocol DeliveryTimeComparison <NSObject>
- (void)compareByDeliveryTime:(id)otherTime;
@end
And then simply #import "DeliveryTimeComparison.h"
in any class where you plan to use @selector(compareByDeliveryTime:)
.
Or alternatively, just import the class header for any object that contains a "compareByDeliveryTime:" method.
Xcode 5 turned this on by default. To turn it off go to "Build Settings" for your target under "Apple LLVM 5.0 - Warnings - Objective C" -> "Undeclared Selector" set it to "NO". This should take care of it.