Thursday, 19 April 2012

json parsing to uitableview


hi ,i using restkit webservices,and have create newsfeed. have json parsing , stuck somewhere.

restapi.m
code:
 -(void)request:(rkrequest*)request didloadresponse:(rkresponse*)response {     else if ([request isget]) {          nslog(@"get response: %@", [response bodyasstring]);                    if ([request.resourcepath isequaltostring:[teamierestapi resourceurl:teamieusernewsfeedrequest]]) { // if it's request user newsfeed              if ([response isok]) {                  nsdictionary * newsfeed = [[response bodyasstring] objectfromjsonstring];                                    [self.delegate requestsuccessful:teamieusernewsfeedrequest withresponse:newsfeed];              }              else {                  [self.delegate requestfailed:[nsstring stringwithformat:@"%i", response.statuscode] forrequest:teamieusernewsfeedrequest];              }          }     -(bool)teamieusernewsfeed:(nsdictionary*)params{      nsstring * newsfeedurl = [teamierestapi resourceurl:teamieusernewsfeedrequest];          [[rkclient sharedclient] get:newsfeedurl queryparams:params delegate:self];  #ifdef debug      nslog(@"newsfeed request sent...");  #endif      return yes;  } 
in newsfeedviewcontroller.m
code:
 // function called once newsfeed loaded  // contains code parse throught json structure  -(void)usernewsfeeddidload:(nsdictionary *)response {            nsdictionary * newsfeed = [response valueforkey:@"thoughts"];            // print 'title' , 'method' of filters      (id item in [newsfeed valueforkey:@"filters"]) {                    nslog(@"filter title: %@ method: %@", [item valueforkey:@"title"], [item valueforkey:@"method"]);      }            // print 'html' of each thought along 'timestamp' , 'real_name' of user posted thought           (id thoughtid in [newsfeed valueforkey:@"thought"]) {                   nsdictionary * thought = [[newsfeed valueforkey:@"thought"] valueforkey:thoughtid];                 nslog(@"message '%@' %@ %@", [[thought valueforkey:@"message"] valueforkey:@"html"], [[[thought valueforkey:@"timestamp"] valueforkey:@"time"] valueforkey:@"text"], [[thought valueforkey:@"user"] valueforkey:@"real_name"]);  }  }  
i want show on uitable view -- html message ,, text time ,, real_name name

getting problem parsing these elements , shwing on tableview..

can in this?
 

one step @ time. able parse values out of json , print them log? getting correct raw response sever?
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment