Reputation: 596
Having this code:
let object = json as? [Any] {
if let questionari=object["questionnarie"] as? [Dictionary<String, AnyObject>]{
}
Compiler (of course) says to me that I can't use a String's index while it's [Any]
: I can't find the proper why to cast it as String.
Upvotes: 1
Views: 5712
Reputation: 1
you can make componentsJoined
string with ","
from any array.
like one line code see bellow example:
let yourStringVar = NSArray(array:ANY_ARRAY_NAME).componentsJoined(by: ",")
Upvotes: 0
Reputation: 4739
Try this code-
if let object = json as? [String:Any] {
if let questionari=object["questionnarie"] as? [Dictionary<String, AnyObject>]{
}
Upvotes: 1
Reputation: 3428
You should be casting your json object as so:
if let object = json as? [String:Any] {
...
Upvotes: 3