下面的代码在模拟器上运行良好,然后在两台设备上崩溃并在一台设备上运行。
我也明白了:
function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded> of Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()).(closure #2)
这可能与将 obj-C 桥接到我的 swift 应用程序有关吗? 有什么建议
var query = PFUser.query()
query?.whereKey("username", notEqualTo: PFUser.currentUser()!.username!)
var users = query?.findObjects()
//Loop through users
if let users = users as? [PFUser]{
for user in users {
//println(user.username)
self.userArray.append(user.username!)
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
// Configure the cell...
cell.textLabel?.text = userArray[indexPath.row]
return cell
}
最佳答案
您想在后台执行查询,以便 UI(主线程)保持响应。尝试以下操作:
if let currentUsername = PFUser.currentUser()?.username {
var query = PFUser.query()!
query.whereKey("username", notEqualTo: currentUsername)
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in
if (error == nil) {
if let users = objects as? [PFUser] {
for user in users {
self.userArray.append(user.username!)
}
}
} else {
// Log details of the failure
println("query error: \(error) \(error!.userInfo!)")
}
}
}
关于ios - 解析查询包装错误,在设备上的模拟器崩溃时工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32341119/