I use a list of parameters like Dictionary<String,AnyObject> in a Swift iOS application to store some parameters that will ultimately be passed to the web service. If I were to save the Bool in this dictionary and then print it, it will appear as "Optional (1)", so it will be converted to int. I can not send int and need it to be "true". Sample code below.
var params = Dictionary<String,AnyObject>() params["tester"] = true println(params["tester"])
How can I make this save as the actual true / false value, and not as an integer?
Warnings
This is used with AFNetworking, so the parameters should look like AnyObject!
The AFNetworking structure is as follows:
manager.GET(<#URLString: String!#>, parameters: <#AnyObject!#>, success: <#((AFHTTPRequestOperation!, AnyObject!) -> Void)!##(AFHTTPRequestOperation!, AnyObject!) -> Void#>, failure: <#((AFHTTPRequestOperation!, NSError!) -> Void)!##(AFHTTPRequestOperation!, NSError!) -> Void#>)
the argument 'parameters' is what I pass to Dictionary<String,AnyObject> as.
dictionary boolean swift
steventnorris
source share