So, i have some places where things are only available after a certain version. One example is some new NFC stuff i've introduced in my app:
@property(nonatomic, retain) NFCNDEFReaderSession *nfcSession;
I also have it in methods, where i get it even though i check for class availability, for example:
if ([NFCNDEFReaderSession class]){
my app works fine, but i get an xcode warning saying
NFCNDEFReaderSession is partial: introduced in iOS 11.0
I have looked around but haven't found a way to tell the compiler that it's fine and get rid of the warning.
Pointers much appreciated!
Add NS_AVAILABLE_IOS(11.0) to the end of the method name. For example:
- (BOOL)tableView:(UITableView *)tableView canHandleDropSession:(id<UIDropSession>)session NS_AVAILABLE_IOS(11.0) {
}
Method calls can be wrapped in the following to silence the new API warning
if (@available(iOS 11.0, *)) {}
You can silence specific warnings on parts of your code by adding Clang “pragmas” around it. In this case:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
// your code
#pragma clang diagnostic pop
Documentation: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
To silence the warning, change the target's "Other warning flags" to either:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With