Cannot invoke 'value' with an argument list of type '(String)'
You probably need to change them to (message as AnyObject).value(forKey:"···")
(adding the forKey:
label).
Do you know what kind of object message
is supposed to be? Repeatedly casting it to AnyObject
is odd. It would be cleaner to create a new variable - let messageObject = message as AnyObject
and then call messageObject.value(forKey:"···")
. (I suspect you really want to cast it to Dictionary
or something like that, in which case you can do messageDictionary["···"]
instead of calling value(forKey:)
.)
Also, in Swift you can do this to reduce redundancy even more:
if let content = messageObject.value(forKey:"content") as? String {
stringContent = content
}