Reputation: 1433
I like to add "abc"
to eventTextField.text
and save it to the attributeeventName
below
eventInformation.setValue(eventTextField.text, forKey: "eventName")
I tried this
let abcString = "abc"
eventInformation.setValue(eventTextField.text?.append(abcString), forKey: "eventName")
but my app is crashing with following error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "eventName"; desired type = NSString; given type = _SwiftValue; value = ().'
Upvotes: 0
Views: 58
Reputation: 285079
The error occurs because append
is mutating but does not return anything,
that's the _SwiftValue; value = ()
(Void)
You need an extra step:
let abcString = "abc"
eventTextField.text?.append(abcString)
eventInformation.setValue(eventTextField.text, forKey: "eventName")
Upvotes: 1