0

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 = ().'

1 Answer 1

1

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")
Sign up to request clarification or add additional context in comments.

Comments

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.