ios - 解析查询包装错误,在设备上的模拟器崩溃时工作正常

标签 ios swift parse-platform

下面的代码在模拟器上运行良好,然后在两台设备上崩溃并在一台设备上运行。

我也明白了:

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/

相关文章:

swift - 将标记图标设置为 UIImage 并使用背景适当调整其大小以使其显示为图标

ios - 如何使用alertcontroller添加警报消息?

android - 如何使用 parse.com 将 Android 设备注册到推送 channel

ios - 解析中的显示维护

c# - xamarin.ios mp3 在屏幕关闭时停止播放

html - 当我点击输入、按钮或其他控件时网页放大

ios - 如何从 Swift4 中的嵌套字典访问值?

ios - 将复选框添加到 IOS 6 AlertView

Swift - 在 LAN 中获取 XML 内容并出现错误 -1004

ios - 转换为字符串的任何对象