Skip to content

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

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

Closed
skotadia opened this issue Feb 1, 2016 · 15 comments
Closed
Labels
type:question Support or code-level question

Comments

@skotadia
Copy link

skotadia commented Feb 1, 2016

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

@gfosco
Copy link
Contributor

gfosco commented Feb 1, 2016

cc @nlutsenko

@nlutsenko
Copy link
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.

@Bill-Niz
Copy link

Bill-Niz commented Feb 1, 2016

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"
}
]
}

@Bill-Niz
Copy link

Bill-Niz commented Feb 1, 2016

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"
}
]
}

@skotadia
Copy link
Author

skotadia commented Feb 1, 2016

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.

@laullon
Copy link
Contributor

laullon commented Feb 1, 2016

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

@laullon
Copy link
Contributor

laullon commented Feb 1, 2016

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"

@nlutsenko
Copy link
Contributor

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

@laullon
Copy link
Contributor

laullon commented Feb 1, 2016

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?

@skotadia
Copy link
Author

skotadia commented Feb 4, 2016

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.

@laullon
Copy link
Contributor

laullon commented Feb 4, 2016

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

parse-community/Parse-SDK-JS#199

@laullon
Copy link
Contributor

laullon commented Feb 4, 2016

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?

@laullon
Copy link
Contributor

laullon commented Feb 4, 2016

I did solve it...
PR: #252

@skotadia
Copy link
Author

skotadia commented Feb 5, 2016

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?

@nlutsenko
Copy link
Contributor

Just merged it, already on master ;)

montymxb pushed a commit to montymxb/parse-server that referenced this issue Feb 14, 2016
Making ParseInstallation subclassable
@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

6 participants