I have the following code:
var episodesToSendToParse = [PFObject]()
let currentPodcast = PFObject(className: "Podcast")
currentPodcast["name"] = name
currentP["user"] = PFUser.currentUser()
for episode in episodes {
let episodes2 = PFObject(className: self.episodesClass)
episodesToParse["title"] = episode.title
episodesToParse["parent"] = currentPodcast
episodesToSendToParse.append(episodes2)
}
PFObject.pinAllInBackground(episodesToSendToParse).continueWithBlock { (task: BFTask!) -> AnyObject! in
if let error = task.error {
print(error)
return task;
}
print("finished pinning")
return task;
}
PFObject.saveAllInBackground(episodesToSendToParse).continueWithBlock { (task: BFTask!) -> AnyObject! in
if let error = task.error {
print(error)
return task;
}
NSNotificationCenter.defaultCenter().postNotificationName("podcastSaved", object: self)
print("finished saving")
return task;
}
}
It saves fine to Parse's servers. The podcast episodes also save locally but the podcast itself overwrites any other podcast I had previously saved, causing my tableview to always load 1 entry only. I thought this may be because of the following (taken from parse.com):
There are a couple of side effects of enabling the local datastore that you should be aware of. When enabled, there will only be one instance of any given PFObject. For example, imagine you have an instance of the "GameScore" class with an objectId of "xWMyZ4YEGZ", and then you issue a PFQuery for all instances of "GameScore" with that objectId. The result will be the same instance of the object you already have in memory.
However I have no idea how to remedy this.
I am running Parse 1.10.0
PFObject, then local data store won't store old and new instances, only new instead. - Juri Noga