2

Using iOS. In tableview I show users all of his contacts (those who are already on server and also those who are not). When he press on contact I must check if contact is on server. If it is then I need to remove it from parse. Else if it's not I save it on parse. Then I refresh the cell to show the user whats updated.

To delete an object from parse I use method [object deleteInBackgroundWithBlock:]. Inside the block I should refresh the cell but which property will tell me that object is removed from server. I tried property isDirty and also property objectId. But both dont change to nil after you delete the from parse.

My qusetion is if there is some option by parse to handle this or I'll create it by myself by adding some property?

Klemen
  • 2,144
  • 2
  • 23
  • 31
  • You have to do a query to see if the contact is in a class then delete it – soulshined Jan 17 '15 at 19:45
  • I know there is a way to query it but I need more intuitive solution. for the sake of performance there need to be another way. – Klemen Jan 18 '15 at 09:59
  • It's 6 lines of code? How much more intuitive do you need? What are you looking for. Specifics maybe would help. Or add code that you've tried or working on that isn't working the way you want it to so we as answers can work from to lead you in a good direction – soulshined Jan 18 '15 at 12:45
  • I wont talk about that number of lines of code talk about the quality of code. But if you look at this example first it calls this method [object deleteInBackgroundWithBlock:] and go to the server to adelete it and then you think its appropriate to go to the server again just to check if the object still exist on server. This shoul be all part of the first metho. This code its not efficient no matter how many lines of code there are. – Klemen Jan 18 '15 at 17:51
  • If your using blocks it has a completion block built into it. That's where you can perform whatever you want to do to update any data app wide that notifies you or your user the information was saved. So if you put a BOOL there for that item stating it successfully updated how do you know what that BOOL says? Parse.com or not you have to do some sort of checks and balances to determine what that BOOL is so your going to have to do a query either way. There's no guarantee deleteinbackground will work because internet variables or no internet at all so your going to have to double check that – soulshined Jan 18 '15 at 20:31
  • Yeah, but then I also should check again if the second attempt to failed by internet failure. What I think that it will be best way is that parse will delete objects id when you remove it from server. Or have a bool that does that. So even if there was a failure in connection the next time when the object connects to server delete its reference from the server. This should make all prety simple and efficient. Just one bool made by them. In my app I solved it by setting objectId to nil by myself. But I wont publish it as a solution because maybe turns out that this case has some drawbacks. – Klemen Jan 18 '15 at 21:34
  • There is no second attempt with deleteInBackground. Your thinking about deleteEventually. If your checking for the contact (Querying it) and then trying to delete it in the same query, there should be no issues or reason to check again? If you query the contact and it's not on the server you can delete it on the spot. Parse does delete the objectID when you delete the row..so again, maybe you should show some code where your having issues with so we could help you. – soulshined Jan 18 '15 at 21:41

0 Answers0