I am using a list of params of type Dictionary<String,AnyObject>
in a Swift iOS application to hold some parameters that will eventually be passed to a webservice. If I were to save a Bool to this dictionary and then print it, it appears as "Optional(1)", so it is being converted to an int. I cannot send an int and need this to be "true". Sample code below.
var params = Dictionary<String,AnyObject>()
params["tester"] = true
println(params["tester"])
How can I get this to save as an actual true/false value and not as an integer?
Caveats
This is being used with AFNetworking, so the parameters are required to be of the form AnyObject!
The AFNetworking structure is as below:
manager.GET(<#URLString: String!#>, parameters: <#AnyObject!#>, success: <#((AFHTTPRequestOperation!, AnyObject!) -> Void)!##(AFHTTPRequestOperation!, AnyObject!) -> Void#>, failure: <#((AFHTTPRequestOperation!, NSError!) -> Void)!##(AFHTTPRequestOperation!, NSError!) -> Void#>)
the 'parameters' argument is what I am passing in the Dictionary<String,AnyObject>
as.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…