khan
khan

Reputation: 49

Getting Error (Code: 105, Version: 1.17.2) with parse

I am trying to save data into my database with Parse but every time I run the code getting following error

[Error]: Invalid field name: name. (Code: 105, Version: 1.17.2)

I have tried removing spaces from the name still the error show's up

   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()
   }

I expected it to be saved in my database

Upvotes: 0

Views: 203

Answers (2)

user3472897
user3472897

Reputation: 250

I just tried @Davi Macêdo's code with XCode 10.3 and Parse 1.17.2 installed manually. Had to include these Framworks:

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

And it worked.

When trying the .add approach, I got this message on Autocomplete about the .add method:

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

I wasn't able to save it to an existing Person class, but was able to save it as an Array in a new class I called Test

So, it seems @Davi Macêdo's code is correct and you are misusing the .add method. It worked on my Test class because it didn't have any columns yet, so it created a name property as an Array, an age property as an Array and a last_name property as another Array. Yours probably didn't work because you already have some data in there as a String.

Please check that.

Upvotes: 0

Davi Macêdo
Davi Macêdo

Reputation: 2984

try:

   override func viewDidLoad() {
       super.viewDidLoad()

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

       person.saveInBackground()
   }

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

Upvotes: 2

Related Questions