【问题标题】:Bool is not a subtype of ObjCBool - swift 2 beta 5Bool 不是 ObjCBool​​ 的子类型 - swift 2 beta 5
【发布时间】:2015-11-02 12:24:52
【问题描述】:

刚刚升级到最新的测试版,我收到了这个错误:

有什么想法吗?

代码是:

func testFileStatusNotifications() {

    let x : XCNotificationExpectationHandler = { (n : NSNotification!) -> Bool in

        // Extract userInfo
        let u = n.userInfo!

        let dict = u.values.first as! [String : Double]
        let percent = dict["percent"]!

        return (percent > 10)
    }

看来处理程序类型一定已经改变了:

typealias XCNotificationExpectationHandler = (NSNotification) -> ObjCBool

因为它现在的类型是ObjCBool

【问题讨论】:

    标签: xcode swift swift2 xcode7-beta5


    【解决方案1】:
    func testFileStatusNotifications() {
    
        let x : XCNotificationExpectationHandler = { (n : NSNotification!) -> ObjCBool in
    
            // Extract userInfo
            let u = n.userInfo!
            let dict = u.values.first as! [String : Double]
            let percent = dict["percent"]!
    
            let ret =  (percent > 10)
            return ObjCBool(ret)
        }
    

    这似乎已经解决了问题。

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 1970-01-01
      • 2014-10-23
      • 2020-12-14
      • 1970-01-01
      • 2019-12-05
      • 2018-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多