Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parse.com invalid type for key, expected string, but got array

I try to save my data to parse.com. I have already pre-made a class in parse.com named 'SomeClass'. This has a column named 'mySpecialColumn' with a datatype of String.

This is the code I try to save data with:

var groupObject = PFObject(className: "SomeClass")
    groupObject.addObject("aaa", forKey: "mySpecialColumn")
    groupObject.saveEventually()

If I run this I get:

Error: invalid type for key mySpecialColumn, expected string, but got array (Code: 111, Version: 1.6.0)

This is how my core at parse.com look like:

This is how my core at parse.com look like

Anyone know why I get this error? I have also tried to to it the lazy way and not pre-make the data class and just create it on the fly, but then it creates all columns as data type Array.

like image 353
TommyF Avatar asked Jan 08 '15 13:01

TommyF


1 Answers

The addObject method is used to append a new object in the array corresponding to the given key. Saving fails because you're trying to save an array where a string is expected.

You have to use setObject:forKey: instead

like image 107
Antonio Avatar answered Sep 18 '22 20:09

Antonio