This is a migrated thread and some comments may be shown as answers.

Parsing field of type "object"

3 Answers 57 Views
Apple iOS SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
smeshko
Top achievements
Rank 1
smeshko asked on 21 Jan 2015, 03:21 PM
Hi,

I have a custom data type with one of the fields being of type "Object". I am trying to save a dictionary of type [String: String] and thought that an Object type would be the right one to choose. Indeed, in the .NET SDK, I just parse it as a JSON object and everything works fine. But in the iOS SDK, the return type from the server is of type "id" and I can't do anything with it - when I try to so much as access it, I get an "exc_bad_access(code=exc_i386_gpflt)" exception. Casting it doesn't work either.

I am using Swift for my application.

Thanks in advance for any help !

Regards,
Ivaylo

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 23 Jan 2015, 12:57 PM
Hello Ivaylo,

Could you please specify:
 -  What is the response returned from the server and the type of the property in the client class model?
 -  Is the problem occuring when serializing or deserializing the objects?
 -  Do you receive a JSON-object in this field from the server? In such case the field should be mapped to a NSDictionary.
 -  The server returns an Id when an item is created - is this the case?

Also, a code snippet or sample project would be of great help.

I look forward to your reply.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
smeshko
Top achievements
Rank 1
answered on 23 Jan 2015, 02:00 PM
Hi Anton,

i've attached a screen shot of what happens, when I try to print the contents of the object to the console (the variable in question is translations ). And this is my model:

@interface Images : EVObject
 
@property (strong, nonatomic) EVFile* image;
@property (strong, nonatomic) NSArray* tags;
@property (assign, nonatomic) BOOL hasText;
@property (assign, nonatomic) NSDictionary* translations;
 
@end
 
As you can see, all the other fields are set properly and can be read without problems. As I said in my original post, I have no problems parsing translations in my Windows Phone/RT application. The weird thing is, when I print the response inside the completion block in dataStore.fetchAll, the translations-Object is properly parsed and printed.
0
Anton Dobrev
Telerik team
answered on 23 Jan 2015, 04:01 PM
Hello Ivaylo,

Thank you for specifying this.

Could you please post the structure of the JSON object returned from the server as well? You can use a HTTP debugging tool like Paw, Postman, Charles, to call the endpoint for the data and observe each item in the response. Please examine if there is a difference between the "translations" values in the objects. Is this happening for each entry in the UI.

Does printing an object for a key in the dictionary instead of the whole dictionary works (you can try to call  NSJsonSerialization on the item beforehand)?

We will need as much as information to reproduce it on our side. Thanks.

Best regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Apple iOS SDK
Asked by
smeshko
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
smeshko
Top achievements
Rank 1
Share this question
or