Im using Parse for server side. And I have a table view with list of Contacts object from Parse. If user taps on object it saves it to parse and if taps again it deletes it from parse.
For saving I use method:
- (void)addContact:(Contact *)contact withBlock:(void (^)(void))completion {
[contact saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (completion) completion();
}];
}
For deleting use this:
- (void)removeContact:(Contact *)contact withBlock:(void (^)(void))completion {
[contact deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
contact.objectId = nil;
if (completion) completion();
}];
}
I set the objectId to nil because I use this property in table view to see if object is allready on parse of it is just on the phone.
The problem is that if user do steps like: save, delete, save.
- Save: the object is created on parse with all the data.
- Delete: the object is deleted from parse.
- Save: the object is created on parse but without data (just objectId).
Is this the normal procedure? On the phone the object has allways all the data even after deletetion method. So I assume if I run save method on the object with all the data, that it will save it to the parse, even if the same object goes through deletion in the past.
Here's a picture of one empty object and one that is saved correctly with all the data:
What are your experience with this? Enjoy resolving this issue and help making wold a better place :)