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