How to check for API availability in Xcode 9
14,344
to answer my own question: I need to mark the method using the NS_AVAILABLE_IOS
macro as follows:
-(BOOL)handleWillPresentNotification:(UNNotificationContent *)notificationContent NS_AVAILABLE_IOS(10_0);
Comments
-
Jan over 1 year
I'm using he
UserNotification
framework that is available only in iOS 10. I am declaring a method that uses this framework and so far, I have been doing the check for the availability as follows:@interface MyService : NSObject #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 -(BOOL)handleWillPresentNotification:(UNNotificationContent *)notificationContent; #endif @end
XCode 9 beta was just release and with this code I get a warning
'UNNotificationContent' is partial: introduced in iOS 10.0 Annotate 'handleWillPresentNotification:withCompletionHandler:' with an availability attribute to silence
The question is how do I annotate this in Objective C code the entire method? I know that Xcode 9 introduced the
if (@available(iOS 10, *)) { // iOS 10 ObjC code }
but how do I wrap the entire method (including its signature) in it?
cheers