Parsing field of type "object"

4 posts, 0 answers
  1. smeshko
    smeshko avatar
    8 posts
    Member since:
    May 2014

    Posted 21 Jan 2015 Link to this post

    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
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 23 Jan 2015 Link to this post

    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.
     
  3. smeshko
    smeshko avatar
    8 posts
    Member since:
    May 2014

    Posted 23 Jan 2015 Link to this post

    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.
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 23 Jan 2015 Link to this post

    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.
     
Back to Top