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

1

7

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.

Stair answered 8/1, 2015 at 13:38 Comment(0)
K
11

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

Kazoo answered 8/1, 2015 at 14:31 Comment(1)
Mohahaha! I love you Antonio! Worked like a charm :)Stair

© 2022 - 2024 — McMap. All rights reserved.