解析时出现错误(代码:105,版本:1.17.2)

时间:2019-07-22 07:30:19

标签: ios swift parse-platform

我正在尝试使用Parse将数据保存到数据库中,但是每次运行代码时都会出现以下错误

  

[错误]:无效的字段名称:名称。 (代码:105,版本:1.17.2)

我尝试从名称中删除空格,但仍然显示错误

   override func viewDidLoad() {
       super.viewDidLoad()

       let person = PFObject(className: "People")
       person.add("dee", forKey: "name")
       person.add("odus", forKey: "last_name")
       person.add(36, forKey: "age")

       person.saveInBackground()
   }

我希望它会保存在我的数据库中

2 个答案:

答案 0 :(得分:0)

尝试:

   override func viewDidLoad() {
       super.viewDidLoad()

       let person = PFObject(className: "People")
       person["name"] = "dee"
       person["last_name"] = "odus"
       person["age"] = 36

       person.saveInBackground()
   }

参考:https://docs.parseplatform.org/ios/guide/#saving-objects

答案 1 :(得分:0)

我刚刚尝试了@DaviMacêdo的代码,并手动安装了XCode 10.3和Parse 1.17.2。 必须包括这些Framworks:

CFNetwork.framework
CoreGraphics.framework
CoreLocation.framework
libz.1.1.3.dylib
MobileCoreServices.framework
QuartzCore.framework
Security.framework
StoreKit.framework
SystemConfiguration.framework

它奏效了。

尝试.add方法时,我在自动完成过程中收到有关.add方法的消息:

Adds an object to the end of the array associated with a given key

我无法将其保存到现有的Person类中,但是能够将其保存为Array(在我称为Test的新类中)

因此,看来@DaviMacêdo的代码正确无误,并且您滥用了.add方法。 它可以在我的Test类上工作,因为它还没有任何列,因此它创建了一个名称属性作为数组,创建了age属性作为数组,并创建了last_name属性作为另一个数组。 您的数据可能无效,因为您已经在其中以字符串形式存储了一些数据。

请检查。