If I have an implicitly unwrapped optional declared in my class which I then reference in a Dictionary
of type [String : Any]
, it doesn\'t get unwr
Any
can represent an instance of any type at all, including function types and optional types.AnyObject
can represent an instance of any class type.And your aString
is an instance object which should not be use to declare in property Area, if you put that line in any function/instance function()
then it will work perfectly, because it will be your instance type then.
In One word, you can not declare instance type in property area in Swift.
override func viewDidLoad() {
let params : [String : Any] = ["myString": aString]
}
Even in Property Area, You can not do like following:
var aString: String! = "String"
var abc = aString
You have to abc = aString
do in any Method()
to get work.
Hope it will help you.