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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Mohahaha! I love you Antonio! Worked like a charm :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.