【问题标题】:how to check UIApplicationDidEnterBackgroundNotification in swift如何快速检查 UIApplication DidEnterBackgroundNotification
【发布时间】:2017-10-23 07:22:24
【问题描述】:

有谁知道转换成这个 if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) { } 迅速

【问题讨论】:

  • 你想在哪里使用它?对我来说似乎有点困惑。
  • 根本不需要这个。这些符号是在 iOS 4 中重新添加的。因此,除非您尝试支持 iOS 3.2 或更早版本(极不可能),否则在 Swift 或 Objective-C 中根本没有理由检查这些符号是否存在。跨度>

标签: ios objective-c swift type-conversion


【解决方案1】:

这可能对你有用。

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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多