2
votes

In result of AFNetworking response I got AnyObject dictionary like structure, which is not casting as Dictionary and fails with error. So I've used structure as following

if let data: AnyObject = responseObject["data"]! {
                if let current_condition: AnyObject = data["current_condition"]! {
                    print(current_condition.valueForKey("FeelsLikeC")!)
                }
            }

That gave me some result which I can't cast as anything and in output it looks like this

(
9
)

How do I cast it as Int?

1

1 Answers

2
votes

Looks like it's an array

if let arr = current_condition.valueForKey("FeelsLikeC") as? NSArray {
      print(arr[0])
}