1

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.

1
  • If object is supposed to be an array then the next line won't compile. Commented Aug 2, 2017 at 10:02

3 Answers 3

3

You should be casting your json object as so:

if let object = json as? [String:Any] {
...
Sign up to request clarification or add additional context in comments.

Comments

1

Try this code-

if let object = json as? [String:Any] {
    if let questionari=object["questionnarie"] as? [Dictionary<String, AnyObject>]{
}

1 Comment

Thank you too, but our colleague was faster :)
0

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: ",")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.