The request results are simple to display:
Reviews encapsulated classes:
Simple display using TableView:
deallistcontroller.m//Handsome _ buy////Created by Beyond on 14-8-14.//Copyright (c) 2014 Com.beyond. All rights reserved.//Click on the dock above the "buy" button corresponding to the controller, above the navigation bar, the right side of the navigation bar is Searchbar, the left side of the navigation bar is a large button (Topmenu) (the interior consists of three small buttons < topmenuitem>) #import "DealListController.h"//The left side of the navigation bar is a large button (top menu) #import "TopMenu.h" #import "DPAPI.h" #import " MetaDataTool.h "#import" Deal.h "#import" City.h "@interface Deallistcontroller () <dprequestdelegate>{// Used to save all deals dictionaries returned by the server and turn them into deal objects Nsmutablearray *_deals;} @end @implementation deallistcontroller-(void) viewdidload{[Super Viewdidload]; 1, set the upper navigation bar, the right is the search bar, the left is a large view (three buttons inside) [Self addnavibarbtn]; _deals = [Nsmutablearray array]; }//1, set the upper navigation bar, the right is the search bar, the left is a large view (three buttons inside)-(void) addnavibarbtn{//1. Notice of City Change kaddallnotes (dataChange)// 2. The search box on the right Uisearchbar *s = [[Uisearchbar alloc] init]; S.frame = CGRectMake (0, 0, 210, 35); S.placeholder = @ "Please enter product name, address, etc."; Self.navigationItem.rightBarButtonItem = [[UibarbuttonItem alloc] initwithcustomview:s]; 3. On the left side of the menu bar, the left side of the navigation bar is a large button (top menu) Topmenu *topmenu = [[Topmenu alloc] init]; 4. For clicking the top button, hold the created bottom pop-up menu (including a contentview and Cover,contentview including ScrollView and Subtitleimgview), This member is passed in by the external assignment that created this topmenu, which is the controller's view, which is all the areas below the navigation bar Topmenu.controllerview = Self.view; Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc] initwithcustomview:topmenu];} Temp--test-(void) datachange{DPAPI *dpapi = [[DPAPI alloc]init]; Log (@ "CurrentCity---%@", [Metadatatool sharedmetadatatool].currentcity); [DPAPI requestwithurl:@ "V1/deal/find_deals" params:@{@ "City": [Metadatatool Sharedmetadatatool].currentcity.name} Delegate:self];} Temp-test-(void) Request: (Dprequest *) Request Didfinishloadingwithresult: (ID) result{[_deals removeallobjects]; Nsarray *arr = result[@ "Deals"]; For (Nsdictionary *dict in arr) {Deal *deal = [[Deal alloc]init]; [Deal setvalueswithdict:dict]; [_deals Addobject:deal]; The next step is to provide TableView with the data source} log (@ "--_deals--%@", _deals); [Self.tableview Reloaddata];} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{log (@ "--------- Numberofrowsinsection____deals.count%d ", _deals.count); return _deals.count;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{static NSString *cellid = @ "Beyond"; UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellid]; if (cell = = nil) {cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstylesubtitle Reuseidentifier:cellid ]; }//Set unique content in cell Deal *deal = [_deals objectAtIndex:indexPath.row]; Cell.textLabel.text = deal.title;//Cell.imageView.image = [UIImage ImageNamed:deal.s_image_url]; Cell.detailTextLabel.text = Deal.desc; Cell.accessorytype = Uitableviewcellaccessorydisclosureindicator; Returns the cell log (@ "--cellforrowatindexpath---%@", Cell.texTlabel.text); return cell;} @end