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

标签 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​​

最佳答案

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

这似乎解决了问题。

关于xcode - Bool 不是 ObjCBool​​ 的子类型 - swift 2 beta 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31922095/

相关文章:

ios - 尝试设置或获取实例变量时出现访问错误

ios - 仪器中的能级数据为空

ios - xib 和代码之间具有不同高度的 UIView

xcode - 如何从命令行设置 Xcode 的自定义路径?

swift2 - Xcode 打印字典的键和值

ios - Swift Button.setText 不适用于渐变

ios - 如何将 UIButton 的标题设置为左对齐?

ios - 容器 View 中有 2 个 UICollectionView,只有一个滚动

ios - 由于自动布局没有计算尺寸,将 subview 添加到自定义 View 最终是错误的

swift - 如何使 map 图钉动画掉落? swift 2.2 iOS 9