iphone - getting empty UITable with AFNetworking JSON Parsing -



iphone - getting empty UITable with AFNetworking JSON Parsing -

i trying parse json info afnetworking afjsonrequestoperation. getting empty uitable reason.

i managed without afnetworking.

could please have @ code google drive

#import "afnetworking.h" #import "afjsonrequestoperation.h" @interface kkviewcontroller () @end @implementation kkviewcontroller @synthesize movies = _movies, count = _count; - (id)initwithstyle:(uitableviewstyle)style { self = [super initwithstyle:style]; if (self) { // custom initialization } homecoming self; } - (void)viewdidload { [super viewdidload]; self.movies = [[nsarray alloc] init]; // info youtube nsurl *url = [[nsurl alloc] initwithstring:@"http://gdata.youtube.com/feeds/api/playlists/pl0l3xlkh7unvldr0zz3xzzup2teny_qap?v=2&alt=jsonc&max-results=50"]; nsurlrequest *request = [[nsurlrequest alloc] initwithurl:url]; afjsonrequestoperation *operation = [afjsonrequestoperation jsonrequestoperationwithrequest:request success:^(nsurlrequest *request, nshttpurlresponse *response, id json) { self.movies = [json valueforkeypath:@"data.items.video"]; // nslog(@@, video) // self.count = [json valueforkeypath:@"data.items.video.thumbnail"]; [self.activityindicatorview stopanimating]; [self.tableview sethidden:no]; [self.tableview reloaddata]; } failure:^(nsurlrequest *request, nshttpurlresponse *response, nserror *error, id json) { nslog(@"request failed error: %@, %@", error, error.userinfo); }]; [operation start]; // uncomment next line preserve selection between presentations. // self.clearsselectiononviewwillappear = no; // uncomment next line display edit button in navigation bar view controller. // self.navigationitem.rightbarbuttonitem = self.editbuttonitem; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } #pragma mark - table view info source - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { // homecoming number of sections. homecoming 0; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // homecoming number of rows in section. if (self.movies && self.movies.count) { homecoming self.movies.count; } else { homecoming 0; } } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellid = @"cell identifier"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellid]; if (!cell) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellid]; } nsdictionary *movie = [self.movies objectatindex:indexpath.row]; nsdictionary *countt = [self.count objectatindex:indexpath.row]; cell.textlabel.text = [movie objectforkey:@"title"]; cell.detailtextlabel.text = [movie objectforkey:@"uploader"]; nsurl *url = [[nsurl alloc] initwithstring:[countt objectforkey:@"hqdefault"]]; [cell.imageview setimagewithurl:url placeholderimage:[uiimage imagenamed:@"placeholder"]]; homecoming cell; } /* // override back upwards conditional editing of table view. - (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath { // homecoming no if not want specified item editable. homecoming yes; } */ /* // override back upwards editing table view. - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { if (editingstyle == uitableviewcelleditingstyledelete) { // delete row info source [tableview deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationfade]; } else if (editingstyle == uitableviewcelleditingstyleinsert) { // create new instance of appropriate class, insert array, , add together new row table view } } */ /* // override back upwards rearranging table view. - (void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { } */ /* // override back upwards conditional rearranging of table view. - (bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath { // homecoming no if not want item re-orderable. homecoming yes; } */ #pragma mark - table view delegate - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { // navigation logic may go here. create , force view controller. /* <#detailviewcontroller#> *detailviewcontroller = [[<#detailviewcontroller#> alloc] initwithnibname:@"<#nib name#>" bundle:nil]; // ... // pass selected object new view controller. [self.navigationcontroller pushviewcontroller:detailviewcontroller animated:yes]; */ } @end [1]: https://docs.google.com/folder/d/0b1epikzi6a5sszvwdxh6vu1pows/edit?usp=sharing

you should move initiation code viewdidload viewwillappear

numberofsectionintableview should homecoming 1 , not 0

iphone json ios6 youtube-api afnetworking

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -