Bool不是ObjCBool​​的子类型 - swift 2 beta 5

时间:2015-08-10 14:22:21

标签: xcode swift swift2 xcode7-beta5

刚刚升级到最新测试版,我收到此错误:enter image description here

有什么想法吗?

代码是:

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

类型

1 个答案:

答案 0 :(得分:0)

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)
    }

这似乎已经解决了问题。