php - Show JSON values in textview with Objective C iOS App -
i'm new objective c i'm trying json data show in textview declared. (the textview called textview) here json data being sent php page:
{ "username": "derekshull", "userbio": "this derekshulls bio", "usersubmitted": "15" }
and here objective c code requesting php url , getting json code:
nsurl *myurl = [[nsurl alloc]initwithstring:@"http://domain.com/json.php"]; nsdata *mydata = [[nsdata alloc]initwithcontentsofurl:myurl]; id myjson = [nsjsonserialization jsonobjectwithdata:mydata options:nsjsonreadingmutablecontainers error:nil]; nsarray *jsonarray = (nsarray *)myjson; (id element in jsonarray) { textview.text = [nslog(@"element: %@", [element description])]; }
the json loading in debug bank. have searched , searched 3 days through stackoverflow , internet , i've come with, don't understand why it's not printing textview.
nsurl *myurl = [[nsurl alloc]initwithstring:@"http://domain.com/json.php"]; nsdata *mydata = [[nsdata alloc]initwithcontentsofurl:myurl]; nserror *error; nsarray *jsonarray = [nsjsonserialization jsonobjectwithdata:mydata options:nsjsonreadingmutablecontainers error:&error]; if(!error) { (id element in jsonarray) { textview.text = [nsstring stringwithformat:@"element: %@",element]; // text view contain last element loop } } else{ textview.text = [nsstring stringwithformat:@"error--%@",[error description]]; }
Comments
Post a Comment