Wednesday 15 September 2010

ios - Error filling data into Dictionary in Method during second call -



ios - Error filling data into Dictionary in Method during second call -

i phone call method send info webservice, when phone call sec time, different value in parameter error.

let userdefault = nsuserdefaults.standarduserdefaults() var params:dictionary<string,string> = dictionary() override init() { var league_id = userdefault.valueforkeypath("userdata.user.active_league") int var hash = userdefault.valueforkeypath("userdata.encrypted") string var token = userdefault.valueforkeypath("userdata.token") string params = ["token": token, "hash": hash, "league_id": string(league_id)] } func switchleague(active_league: int) -> bool { var switched = false var url = "switchleague" var user_id = userdefault.valueforkeypath("userdata.user.id") int // next error shown code line below // thread 1:exc_bad_access (code=exc_i386_gpflt) params.updatevalue(string(active_league), forkey: "active_league") params.updatevalue(string(user_id), forkey: "user_id") var resp:anyobject = conn.postarraytourl(base + url, params: params) switched = resp.valueforkey("success") bool if(switched == true) { var league_id = resp.valueforkey("active_league") int userdefault.setobject(league_id, forkey: "userdata.user.active_league") userdefault.synchronize() } homecoming switched }

i pretty much same in different method , have no problems that. thought on that? lot

i had same problem , solved using nsmutabledictionary instead of native swift dictionary

ios xcode swift ios8

No comments:

Post a Comment