从 Parse Data Browser 检索对象时,我无法获取对象属性。这发生在我从“@NSManaged var friends”更改为“dynamic var friends”之后。甚至“名称”在 User.logInWithUsernameInBackground 块中也显示 nil,这很疯狂,因为登录成功。用户的 ACL 设置为“公共读取”。
用户对象:
class User : PFUser, PFSubclassing {
dynamic var friends:[User]!
dynamic var name:String!
override class func load() {
self.registerSubclass()
}
}
与朋友一起检索用户。println 显示为零
var query = User.query()
query.includeKey("friends")
query.getObjectInBackgroundWithId(currentUser.objectId) {
(pfObject: PFObject!, error: NSError!) -> Void in
if pfObject != nil {
var user = pfObject as User
var friends = user.friends as [User]
println("friends: \(friends)") //nil
} else {
println(error)
}
}
登录。println 显示为零
User.logInWithUsernameInBackground(USERNAME, password:PASSWORD) {
(user: PFUser!, error: NSError!) -> Void in
if user != nil {
println("Logged in with user: \(user.name)") //nil
} else {
println(error)
}
}