I updated an external Swift library, and one of the methods has changed face from:
public convenience method(data:NSDictionary?) { ... }
to:
public convenience method(data:[String: AnyObject]?) { ... }
What does this mean?
Initially, with the old, @{@"optionA":@YES}
was passed as data
argument. But now with the new I need to pass two items. I was thinking to just write @{@"optionA":@YES,@"optionB":@NO}
, is that correct?
It just means that the parameter is a swift dictionary now and no Objective-C NSDictionary anymore.
To pass data, just use square brackets instead of curly brackets and remove the "@" (in swift)
["optionA":true, "optionB": false]
If you are calling the method from Objective-C, the method parameter should be exposed as NSDictionary and you were right with @{@"optionA":@YES,"optionB":@NO}
but missed a @-sign before optionB
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.