iOS_21團購_發送請求擷取【點評】資料

來源:互聯網
上載者:User

標籤:ios   ipad   團購   伺服器   

請求結果簡單顯示:


用到的點評封裝的類:







使用tableView簡單展示:

////  DealListController.m//  帥哥_團購////  Created by beyond on 14-8-14.//  Copyright (c) 2014年 com.beyond. All rights reserved.//  點擊dock上面的【團購】按鈕對應的控制器,上面是導覽列,導覽列右邊是searchBar,導覽列左邊是一個大按鈕(TopMenu)(內部由三個小按鈕組成<TopMenuItem>)#import "DealListController.h"// 導覽列左邊是一個大按鈕(頂部菜單)#import "TopMenu.h"#import "DPAPI.h"#import "MetaDataTool.h"#import "Deal.h"#import "City.h"@interface DealListController ()<DPRequestDelegate>{    // 用於儲存伺服器返回的所有deals字典,並轉成一個個deal對象    NSMutableArray *_deals;}@end@implementation DealListController- (void)viewDidLoad{    [super viewDidLoad];    // 1,設定上方的導覽列,右邊是搜尋bar,左邊是一個大的VIEW(內有三個按鈕)    [self addNaviBarBtn];    _deals = [NSMutableArray array];        }// 1,設定上方的導覽列,右邊是搜尋bar,左邊是一個大的VIEW(內有三個按鈕)- (void)addNaviBarBtn{    // 1.監聽城市改變的通知    kAddAllNotes(dataChange)        // 2.右邊的搜尋方塊    UISearchBar *s = [[UISearchBar alloc] init];    s.frame = CGRectMake(0, 0, 210, 35);    s.placeholder = @"請輸入商品名、地址等";    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:s];        // 3.左邊的功能表列,導覽列左邊是一個大按鈕(頂部菜單)    TopMenu *topMenu = [[TopMenu alloc] init];    // 4.用於點擊頂部按鈕時,容納建立出來的底部快顯功能表(包括一個contentView和cover,contentView又包括scrollView和subTitleImgView),本成員是由建立此TopMenu的外部賦值傳入, 這裡是控制器的view,就是導覽列下面的所有地區        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];             // 接下來就可以給tableView提供資料來源了    }   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];    }    // 設定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;    // 返回cell    log(@"--cellForRowAtIndexPath---%@",cell.textLabel.text);    return cell;}@end









聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.