ios - Loop through AnyObject Array -
my data contains user data of various values (which can parse out) balances each user in number of currencies.
i can parse out user data. example:
if let add2 = parsed["address"] as? string { println("alert: \(add2)") } i can lists of balances:
if let findbalances = parsed["balances"]{ println("find balances: \(findbalances)") and can individual values:
var balance11:double = findbalances[0]["available_amount"] as! double/100 var curr11:string = findbalances[0]["currency"] as! string the array anyobject. if try:
for currency in findbalances { i
type anyobject not conform sequence
so tried downcast string:
if let findbalances = parsed["balances"] as? string { currency in findbalances { and output blank.
yet know values there.
i stumped; how loop through anyobject array in swift?
i think you're close. in code "for currency in findbalances {", should know currency dictionary, not currency. looking this?
for balance in findbalances as! [[string: anyobject]] { let currency = balance["currency"] as! string //do currency }
Comments
Post a Comment