Ios 如何在swift中检查UIApplicationIdentinterBackgroundNotification

Ios 如何在swift中检查UIApplicationIdentinterBackgroundNotification,ios,objective-c,swift,type-conversion,Ios,Objective C,Swift,Type Conversion,有人知道这件事吗 if(&UIApplicationIdentinterBackgroundNotification&&UIApplicationWillEnterForegroundNotification){ }在swift中,这可能对您有利 var didEnterBackgroundNotificationName = NSNotification.Name.UIApplicationDidEnterBackground.rawValue var willEnterForgroundNo

有人知道这件事吗 if(&UIApplicationIdentinterBackgroundNotification&&UIApplicationWillEnterForegroundNotification){
}在swift中,这可能对您有利

var didEnterBackgroundNotificationName = NSNotification.Name.UIApplicationDidEnterBackground.rawValue
var willEnterForgroundNotificationName = NSNotification.Name.UIApplicationWillEnterForeground.rawValue
let address1 : Int = address(of: &didEnterBackgroundNotificationName)
let address2 : Int = address(of: &willEnterForgroundNotificationName)

if address1 != 0 && address2 != 0 {
    // code here
}

你想在哪里使用它?。我觉得有点困惑,根本没必要这样。这些符号被添加回iOS 4。因此,除非您试图支持iOS 3.2或更早版本(极不可能),否则在Swift或Objective-C中根本没有理由检查这些符号是否存在。