iphone - Xcode Parse Json Data -


my code below working, before, stopped working. tell me i'm doing wrong?

output of nslog():

2013-05-14 16:06:35.475 run.ph[1502:19a03] background = (null) 2013-05-14 16:06:35.476 run.ph[1502:19a03] logo = (null) 2013-05-14 16:06:35.476 run.ph[1502:19a03] json = (null) 2013-05-14 16:06:35.476 run.ph[1502:19a03] welcome = (null) 

codes:

- (void)viewdidload {      [super viewdidload];      // additional setup after loading view, typically nib.      nsstring *urlstring = [nsstring stringwithformat:@"http://run.ph/json/test_json_dyna.jsp"];      nsurl *url = [nsurl urlwithstring:urlstring];      nsdata *data = [nsdata datawithcontentsofurl:url];      if(data != nil)     {          nserror *error;          _json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error];          _welcomemessage.text = [[_json objectforkey:@"welcome"] objectforkey:@"message"];          nsstring *background = [[_json objectforkey:@"welcome"] objectforkey:@"background"];          nsstring *logo = [[_json objectforkey:@"welcome"] objectforkey:@"logo"];           nslog(@"background = %@", background);         nslog(@"logo = %@", logo);         nslog(@"json = %@", _json);         nslog(@"welcome = %@", _welcomemessage.text);           nsurl *urlbackground = [nsurl urlwithstring:background];         nsdata *databackground = [nsdata datawithcontentsofurl:urlbackground];          [_background setimage:[uiimage imagewithdata:databackground]];          nsurl *urllogo = [nsurl urlwithstring:logo];         nsdata *datalogo = [nsdata datawithcontentsofurl:urllogo];          [_logo setimage:[uiimage imagewithdata:datalogo]];     }     else     {         nslog(@"error!");     }       [self.view reloadinputviews]; } 

just nslog url response wats wrong json. try

nsstring *respo = [nsstring stringwithcontentsofurl:[nsurl urlwithstring:[urlstring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]]; nslog(@"response - %@",respo);   

it has return "\r" , newline character "\n" response.

check

enter image description here

edit
url working fine, problem web service end.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -