gpt4 book ai didi

swift - 获取 PFUser 的用户名 (Parse.com)

转载 作者:行者123 更新时间:2023-11-30 10:20:09 25 4
gpt4 key购买 nike

我正在尝试获取 PFUser 的用户名。下面的代码在没有此行的情况下也可以工作:var username = nameId.username as String 但添加它后, Collection View 不会显示任何结果。有什么想法吗?

var query = PFQuery(className:"Chat")
// query.whereKey("user", equalTo:currentUser)
query.whereKey("rideId", equalTo:currentObjectId)
query.orderByAscending("createdAt")

query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
// The find succeeded.
NSLog("Successfully retrieved \(objects.count) scores.")
// Do something with the found objects
for object in objects {
NSLog("%@", object.objectId)

var testId = object.objectId

println(testId)

self.orderedIdArray.append(testId)

var message = object.objectForKey("message") as String
self.messageString = message
self.messageArray.append(self.messageString)
println(message)

var nameId = object.objectForKey("user") as PFUser
var username = nameId.username as String
self.nameString = username
self.namesArray.append(self.nameString)

self.collectionView?.reloadData()

}

} else {
// Log details of the failure
NSLog("Error: %@ %@", error, error.userInfo!)
}

}

最佳答案

它现在正在使用这条线:

query.includeKey("用户")

关于swift - 获取 PFUser 的用户名 (Parse.com),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27238883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com