I have a subclass of PFUser with additional fields:
class User: PFUser {
@NSManaged var myLists: [BuyList]
@NSManaged var receivedlists: [BuyList]
@NSManaged var users: [User]
override class func initialize() {
struct Static {
static var onceToken : dispatch_once_t = 0;
}
dispatch_once(&Static.onceToken) {
self.registerSubclass()
}
}
}
BuyList is subclass of PFObject.
I create BuyList object, make some horribly things with it and append to the User.myLists. After that I call:
User.currentUser()!.saveInBackground()
In Parse dashboard I have this value in 'myLists' field:
[{"__type":"Pointer","className":"BuyList","objectId":"D5sGbsEhio"}]
But on device object is:
<BuyList: 0x7bab9b80, objectId: D5sGbsEhio, localId: (null)> {
//Empty body here
}
How I can receive User object and it's property's?
I try to load user before HomeScreen opened, so I replaced open method with:
private func openHomeScreen() {
self.loadList(0) { () -> Void in
Utils.setRootController("HomeController")
}
}
private func loadList(var index: Int, completition: () -> Void ) {
User.currentUser()!.myLists[index].fetchIfNeededInBackgroundWithBlock { (object: PFObject?, error: NSError?) -> Void in
index++
if index == User.currentUser()!.myLists.count {
completition()
} else {
self.loadList(index, completition: completition)
}
}
}