我正在使用仅在iOS 10中可用的UserNotification
框架。我正在声明一种使用此框架的方法,到目前为止,我一直在检查可用性,如下所示:
@interface MyService : NSObject
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
-(BOOL)handleWillPresentNotification:(UNNotificationContent *)notificationContent;
#endif
@end
XCode 9 测试版刚刚发布,使用此代码我收到警告
"UNNotificationContent"是部分的:在iOS 10.0中引入 注释"handleWillPresentNotification:withCompletionHandler:",并将可用性属性设置为静音
问题是如何在 Objective C 代码中对整个方法进行注释?我知道 Xcode 9 引入了
if (@available(iOS 10, *)) {
// iOS 10 ObjC code
}
但是如何将整个方法(包括其签名(包装在其中呢?
干杯
来回答我自己的问题:我需要使用NS_AVAILABLE_IOS
宏标记该方法,如下所示:
-(BOOL)handleWillPresentNotification:(UNNotificationContent *)notificationContent NS_AVAILABLE_IOS(10_0);