ios - Store Value in NSUser Default -
this code perform ...
nsdictionary *dictionary = [nsjsonserialization jsonobjectwithdata:responseobject options:kniloptions error:&error]; [[nsuserdefaults standarduserdefaults] setobject:[dictionary objectforkey:@"user_id"] forkey:@"user_id"]; [[nsuserdefaults standarduserdefaults] synchronize]; nslog(@"%@",[[nsuserdefaults standarduserdefaults] objectforkey:@"user_id"]); and here json response
{ "flag": "true", "message": "success", "data": [ { "username": "ankurk", "user_id": "16", "email": "ankurk.psk@gmail.com" } ] } but stuck store value user id in user default 1 please me happen here ?
thank
nsdictionary *dictionary = [nsjsonserialization jsonobjectwithdata:responseobject options:kniloptions error:&error]; nsarray *array = [dictionary objectforkey:"data"]; nsdictionary *datadictionary=[array objectatindex:0]; [[nsuserdefaults standarduserdefaults] setobject:[datadictionary objectforkey:@"user_id"] forkey:@"user_id"]; [[nsuserdefaults standarduserdefaults] synchronize];
Comments
Post a Comment