Skip to content

Cloud function retuning array of PFObject, can not be cast in iOS (Swift) #112

Description

@skotadia

I am returning PFObjects from cloud function(s) and in my app (iOS SDK), I am using Subclassing. However, it gives error:

fatal error: NSArray element failed to match the Swift Array Element type

It works fine with api.parse.com but not with my local parse-server. Thanks

Activity

  1. gfosco commented on Feb 1, 2016

    @gfosco
    Contributor
  2. nlutsenko commented on Feb 1, 2016

    @nlutsenko
    Contributor

    Sounds strange - any chance you can try to print out that array? It might be coming back as array of dictionaries instead of array of Parse Objects / Pointers - that's the only reason that comes to my mind.

  3. Bill-Niz commented on Feb 1, 2016

    @Bill-Niz

    Self hosted parse-server
    {
    "result": [
    {
    "copy": "undefined",
    "createdAt": "2016-02-01T10:00:20.702Z",
    "duration": 15,
    "endTime": {
    "__type": "Date",
    "iso": "2016-02-01T14:15:00.000Z"
    }
    ]
    }

  4. Bill-Niz commented on Feb 1, 2016

    @Bill-Niz

    Parse.com
    {
    "result": [
    {
    "__type": "Object",
    "className": "Program",
    "copy": "undefined",
    "createdAt": "2016-02-01T11:00:39.837Z",
    "duration": 15,
    "endTime": {
    "__type": "Date",
    "iso": "2016-02-01T14:45:00.000Z"
    }
    ]
    }

  5. skotadia commented on Feb 1, 2016

    @skotadia
    Author

    I haven't print them out, At least in XCode debugger, it was showing NSDirectory. I will confirm it if there is difference between them.

  6. laullon commented on Feb 1, 2016

    @laullon
    Contributor

    I have the same problem, I think is because the result is missing "__type" and "className"

  7. laullon commented on Feb 1, 2016

    @laullon
    Contributor

    I thin this can be related to parse JS lib, ParseObject.js have 2 methods:

    • _toFullJSON , this one add the "__type" and "className"
    • toJSON , this one don't....

    and the express framework is using "toJSON"

  8. nlutsenko commented on Feb 1, 2016

    @nlutsenko
    Contributor

    Yup - it needs the __type notation to be able to recognize that it's a full object.

  9. laullon commented on Feb 1, 2016

    @laullon
    Contributor

    I'm trying to use a "json replacer" function to use _toFullJSON function, or to add the both properties, bu, no luck so far...

    Any recommendation?

  10. skotadia commented on Feb 4, 2016

    @skotadia
    Author

    I am not hands on with nodejs (that was the reason, I started with Parse), Anyone has any idea or work around to continue my migration? At this point I have stuck. Thanks a lot.

  11. laullon commented on Feb 4, 2016

    @laullon
    Contributor

    I opened a bug on the Parse-SDK-JS, I think the problem is there.

    parse-community/Parse-SDK-JS#199

  12. laullon commented on Feb 4, 2016

    @laullon
    Contributor

    I know how to solve this when I return this:
    response.success(np);

    But no if I return something like this:
    response.success({ photo : np });
    or any other object that contains a ParseObject.

    any idea?

  13. laullon commented on Feb 4, 2016

    @laullon
    Contributor

    I did solve it...
    PR: #252

  14. skotadia commented on Feb 5, 2016

    @skotadia
    Author

    German: Thanks a lot. I just tested out and it works like a charm. Do you know when is it going to be in master branch?

  15. nlutsenko commented on Feb 5, 2016

    @nlutsenko
    Contributor

    Just merged it, already on master ;)

  16. added a commit that references this issue on Feb 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions