zoukankan      html  css  js  c++  java
  • 11

    11

    //下拉刷新数据

    - (void)refreshStateChange:(UIRefreshControl *)refreshC

    {

        /*

         URLhttps://api.weibo.com/2/statuses/friends_timeline.json

        

         请求参数:

         access_token   采用OAuth授权方式为必填参数,其他授权方式不需要此参数,OAuth授权后获得。

         count          单页返回的记录条数,最大不超过100,默认为20

         since_id   若指定此参数,则返回IDsince_id大的微博(即比since_id时间晚的微博),默认为0

         */

       

       

        WJAccount *act = [WJAccountToolreadAct];

        //请求管理者

        AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManagermanager];

        //拼接请求参数

        NSMutableDictionary *params = [NSMutableDictionarydictionary];

        params[@"access_token"] = act.access_token;

        WJStatus *firstStatus = [self.statusesfirstObject];

        if (firstStatus) {

            params[@"since_id"] = firstStatus.idstr;

        }

        //发送请求

        [mgr GET: @"https://api.weibo.com/2/statuses/friends_timeline.json"parameters: params success:^(AFHTTPRequestOperation *operation, id responseObject) {

           

            //        NSArray *dictArray = responseObject[@"statuses"];

            //        for (NSDictionary *dict in dictArray) {

            //            WJStatus *status = [WJStatus objectWithKeyValues: dict];

            //            [self.statuses addObject: status];

            //        }

           

            //字典数组转成模型数组

            NSArray *newstatuses = [WJStatusobjectArrayWithKeyValuesArray: responseObject[@"statuses"]];

            //将最新的微博数据添加到总数组后面

            NSRange range = NSMakeRange(0, newstatuses.count);

            NSIndexSet *set = [NSIndexSetindexSetWithIndexesInRange: range];

            [self.statusesinsertObjects: newstatuses atIndexes: set];

           

            //刷新表格

            [self.tableViewreloadData];

           

            //结束刷新状态

            [refreshC endRefreshing];

           

            //显示得到最新微博的数量

            [selfshowNewStatusCount: newstatuses.count];

           

            //把最新未读数清空(显示在tabbar上的)

            self.tabBarItem.badgeValue = nil;

           

        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

           

            [refreshC endRefreshing];

            WJLog(@"获取当前登录用户及其所关注用户的最新微博失败-%@", error);

        }];

    }

  • 相关阅读:
    TIF转JPG
    跨线程取出控件的值的写法(不是跨线程赋予控件值)
    oracle根据正则表达式查找对应的字段
    oracle数据库连接字符串
    access检测表没有的字段,添加之
    解决 Unable to load DLL 'OraOps9.dll': 找不到指定的模块。 (Exception from HRESULT: 0x8007007E)
    oracle关键字使用
    to_number,Extract oracle的关键字
    OracleCommand.CommandText 无效
    调用带参数的线程两种方法
  • 原文地址:https://www.cnblogs.com/w413133157/p/4367119.html
Copyright © 2011-2022 走看看