有什么想法吗?
代码是:
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/