I've been struggling with an existing project which uses .plist to save the data from the user which is logged in.
On crashlytics I've found a problem which results in a crash. When a user updated his profile in the web-application it causes a crash in the application.
The error says it's because I'm trying to set a non-property-list object. But I've already tried to add all the fields into the .plist-file.
Here you can see the changed .plist
I'm not sure but I think there is something wrong with the value "street"
Thanks in advance!
Indeed, the problem might come from the 'street' object. Because according to your plist, it should be a 'text', but it seems to be an NSArray...
To get the text value you should do something like that :
NSString *streetString = ((NSArray *)[dict objectForKey:#"street"]).firstObject;
And save that value instead.
Related
Swift / iOS
Can anyone tell me if it is possible to specify the PFObject objectId value when creating new objects?
I've obviously attempted but the save fails. (which might just be the answer)
The reason I am asking is I wondered if anyone had found a "trick" that would allow me to specify.
I am using PFObject.saveInBackground { method to persist the new object.
No you can not. Parse sets the objectId on the server during the save operation.
The reason your operation is failing is because Parse is looking for an object on the server with the id that you are specifying and is then trying to update that object but it cannot find the object.
I'm facing an issue with save eventually.
I'm retrieving an object from Parse the object contains a pointer for a User.
I'm trying to update the object and save it with a different user.
object.incrementKey("Likes")
object.addObject((PFUser.currentUser()?.objectId)!, forKey: "LikesUsers")
object.saveEventually()
it works once or twice and then it generates this Error and the app crashes :
Caught "NSInternalInconsistencyException" with reason "User cannot be
saved unless they have been authenticated via logIn or signUp
I think the user pointer shouldn't be saved ! and I would like to know if there is any function to tell Parse to not save the User and modify the dirty value.
You should explain what kind of object we're looking at. Is this a "likes" object, or is the "photo" object?
I'm guessing object is a photo or sth that other users kan like. And that what you're trying to do is to save a "like" for the current photo.
Your screenshot is not showing us the LikesUsers column, which is the one you are trying to save to. I will therefore guess that LikesUsers is an array of pointers.
Your code should then be like this:
object.incrementKey("Likes")
object.addObject(PFUser.currentUser()!, forKey: "LikesUsers")
object.saveEventually()
For this to work, the current user must of course be authenticated already.
Be aware that if you have a lot of users, you may face problems if there are thousands of likes on a photo when you store them all in an array of pointers.
I am using the Parse.com Store template and I am having trouble accessing parts of my data browser. I need to access a column called 'link' from the data browser and I do not seem to be able to. If I run linkLabel.text = self.product[#"link"]; and then NSLog it NSLog(#"%#", linkLabel.text]);
The value is returned as null.
So I decided to check what the value of 'link' is. I ran NSLog(#"%#", self.product[#"link"]); and still it returned null. I thought well there is something wrong with 'link' so i tried 'name' NSLog(#"%#", self.product[#"name"]);still... nothing (it returns (null)).
So I have no idea how to access link or name from my ViewController. I have even added #property (nonatomic, strong) PFObject *product; and still nothing.
I am able to access all of those objects but they do not get accessed by the servers. Now in my other view (that Parse.com built) when I run linkLabel.text = self.product[#"link"]; and then log it I get the value off of my data browser. So Basically I am doing something wrong and I need help! Thank you so much!
To access your data from parse ,you need to fire query and in return you get data for which you have provided a condition. Here's go with this link and parse and also go for google. You will find your way to fetch your data from parse. After receiving data you could populate the label's or view controller you want to.
I've researched tons of questions and documents about CoreData returning faults instead of actual values:
Relationship 'whiskers' fault on managed object (0xb7abab0)
This happens when I'm trying to get the count for the number of whiskers, such as:
self.numWhiskersLabel.text = [NSString stringWithFormat:#"%d", cat.whiskers.count];
Even if I try to log the whiskers set directly I still get a fault:
NSLog(#"whiskers: %#", cat.whiskers);
I understand that "Core data will not return full object until there is a need to access the actual value of that object. Each of your returned objects will be a 'fault' until this point." That's great, but there is a need to access the actual value at this point. I need the value right now! So how do I get out of this oxymoron? How can accessing the count of a Set not be considered needing the value?
I didn't get any feedback from my comment so I'm just going to assume whiskers is a set of NSManagedObjects
The set wont be loaded initially because internally it's coming from another table in the db. When you access .whiskers.count it still doesn't need to go and get the data yet, because all you're wanting is the number of whiskers in the set.
When you pull a whisker out of the set, then it will be faulted, try doing
NSLog(#"whiskers: %#", [cat.whiskers.anyObject anyProperty]);
That should give you a loaded NSManagedObject.
This is an error condition. Something is wrong with that NSManagedObject instance. Either it was deleted before you accessed it or you are trying to touch it from the wrong thread.
Please edit your question and show the code that is accessing that NSManagedObject.
Also, what happens when, in the debugger, you just do a po cat? Do you see the full Cat object or is that giving a fault error as well?
With help from the great posts here, I understand the error. But I need some clarification please.
Say my managed object context (schema) has 3 tables (entities), and say each entity had 3 attributes of which one attribute for each entry is NOT optional.
So now for the first time, my app creates a managed object for the first entity, filling its mandatory attribute; app has not created managed objects for the second and third entities yet - didn't have to yet. When I try to save the context at this point, I get error code 1570. Is it because I have not filled out values for the second and 3rd entities?
I am not sure if this helps you.
But The cocoa error 1570 means that mandatory fields are not filled in. So please make sure your mandatory fields are not nil.
iphone Core Data Unresolved error while saving
Yep it was a mandatory field that was not filled in. The post above showed me which field.
If you have previously run it on your device (or simulator) with the attribute set as mandatory and then changed it to optional, delete the app from the device before running again. That was the problem for my app.
Hope that helps someone! :-)
In my case, I was setting a mandatory BOOL property directly as YES or NO, but you should use
NSNumber numberWithBOOL
in order to make it work.