parse.com键,预期字符串的无效类型,但得到数组

时间:2021-08-03 16:55:51

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.

我尝试将我的数据保存到parse.com。我已经预先在parse.com上创建了一个名为'SomeClass'的类。它有一个名为'mySpecialColumn'的列,其数据类型为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)

错误:密钥mySpecialColumn的无效类型,预期字符串,但得到数组(代码:111,版本:1.6.0)

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

这就是我在parse.com上的核心外观:

parse.com键,预期字符串的无效类型,但得到数组

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 个解决方案

#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.

addObject方法用于在对应于给定键的数组中追加新对象。保存失败,因为您尝试将数组保存在需要字符串的位置。

You have to use setObject:forKey: instead

您必须使用setObject:forKey:而不是

#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.

addObject方法用于在对应于给定键的数组中追加新对象。保存失败,因为您尝试将数组保存在需要字符串的位置。

You have to use setObject:forKey: instead

您必须使用setObject:forKey:而不是