I am trying to get values from a JSON array and I get the error message "Cast from 'XCUIElement!" for an unrelated string always fails. "
I am using Xcode 7 with iOS 9.1.
My code is as follows:
let url = NSURL(string: urlAsString)! let urlSession = NSURLSession.sharedSession() let jsonQuery = urlSession.dataTaskWithURL(url, completionHandler: { data, response, error -> Void in if (error != nil) { print(error!.localizedDescription) } do { let jsonResult = (try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers)) as! NSMutableArray // print (jsonResult) for usernames in jsonResult { let influencer_username = usernames["influencer_username"] as! String print("influencer_username: \(influencer_username)") }
source share