Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loaded PFObject with NSCoding are not marked as dirty #14

Open
SebC99 opened this issue Jun 23, 2014 · 6 comments
Open

Loaded PFObject with NSCoding are not marked as dirty #14

SebC99 opened this issue Jun 23, 2014 · 6 comments

Comments

@SebC99
Copy link

SebC99 commented Jun 23, 2014

Hello,
I'm trying to use Parse-NSCoding to implement a local storage functionality in my Parse iOS project, and I try to sync the data at launch:

  • I load PFObjects from NSUserDefaults
  • I load PFObjects from parse
  • I compare & update

I have an issue when I delete a PFObject from parse (for example with another device of the same user, or with a webapp):

  • I load the object from NSUserDefaults
  • I found nothing in Parse
  • I want to save it again in Parse, but I can't because the PFObject loaded from NSUserDefaults is not marked as Dirty... so Parse considered it to be already saved...

Do you think a PFObject created through NSUserDefaults loading should be dirty or not?

Thanks

@mitchellporter
Copy link

I've been experiencing the same problem. See the following 2 links in order for full details:

  1. http://stackoverflow.com/questions/24718404/pfobject-does-not-reflect-successfully-saved-changes-in-the-parse-data-browser#comment38355958_24718404
  2. http://stackoverflow.com/a/24767622/3344977

The only solution I found was what I described in the second link. I just have to fetch the object again from Parse using the unarchived object's objectId property, and then make my changes to the fetched object. I am then able to save those changes to Parse and have them actually show up in the Data Browser.

This problem only started happening a couple weeks ago and I'm not sure why.

@michaeleisel
Copy link

I have a solution for this. Instead of calling [self->operationSetQueue removeAllObjects] in -initWithCoder, try calling [self->operationSetQueue[0] removeAllObjects]. I'm still testing it myself, so let me know if you run into any issues with it!

@SebC99
Copy link
Author

SebC99 commented Nov 19, 2014

Nice one.
What I do is:

//Mark PFObject as not dirty
[self->operationSetQueue removeAllObjects];
[self->operationSetQueue addObject:[NSMutableDictionary new]];

//Reflect PFObject data as server data
[self setValue:[[NSMutableDictionary alloc] initWithDictionary:self->estimatedData copyItems:NO] forKey:@"serverData"];

@michaeleisel
Copy link

Thanks for the tip. Have you made any changes to any other parts of the code? I'm still having some issues with PFFile and PFObject serialization

@SebC99
Copy link
Author

SebC99 commented Nov 19, 2014

I commented the allParsePropertieslines in initWithCodermethod and removed PFGeoPoint and PFACL categories as they are already in the new Parse SDK

@michaeleisel
Copy link

Could you just send me your current PFObject and PFFile categories? Also, are you doing anything to avoid saving duplicate PFFiles? I'd heard Parse cached the file data sometimes to disk, but I haven't figured out how to get a PFFile just like it is when it comes back from the server with no data, which Parse would presumably be able to use its cache with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants