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
An API, or application programming interface, is used to pass data back and forth between software apps in a formalized way.
Availability checking in Swift gives us the ability to ask whether the user is running a specific or newer version of an operating system, and run code only if that test passes. This allows us to use the latest functionality from iOS, macOS and so on, while also degrading gracefully for users on older iOS versions.
API stands for Application Programming Interface. It is a programmatic way to be able to access functions and data of other apps.
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);
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