I have this func:
typealias KeyValue = Dictionary<String,AnyObject>
func response( response: NSHTTPURLResponse!, data: AnyObject!, error: NSError! ) {
var resData = data as NSDictionary
if( resData["status"] as Int == 1 ){
var content = resData["content"] as Array<KeyValue>
for player in content {
let id : Int = player["id"]
let score : Int = player["score"]
let name : String = player["name"]
players[ id ]!.setName( name )
players[ id ]!.setScore( score )
}
} else {
println( resData["error"] )
}
self.playersList.reloadData()
}
and i'm getting this error:
'(String, AnyObject)' is not convertible to 'Int'
on this lines
let id : Int = player["id"]
let score : Int = player["score"]
let name : String = player["name"]
I can't figure out why
content is Array
-> player is KeyValue
-> player is Dictionary
-> player["id"] is AnyObject
so why he think that player["id"] is '(String, AnyObject)'??
Thanks
UPDATE
Change to this fix that error:
let id = player["id"]! as Int
let score = player["score"]! as Int
let name = player["name"]! as String
But now i'm getting this in run-time:
Thread 5: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT,subcode=0xdefe)