1 #import "YSHomeViewController.h"2 #import "Uiimage+ys.h"3 #import "Uibarbuttonitem+ys.h"4 #import "YStitleButton.h"5 #import "AFNetworking.h"6 #import "YSaccountTool.h"7 #import "YSaccount.h"8 #import "uiimageview+webcache.h"9 #import "YSStatus.h"Ten #import "YSUser.h" One #import "MJExtension.h" A @interfaceYshomeviewcontroller () -@property (nonatomic,strong) Nsarray *statuses; - @end the @implementationYshomeviewcontroller - --(void) Viewdidload - { + [Super Viewdidload]; - [self setupnavbar]; + [self setupweibolist]; A at } --(void) Setupweibolist - { -Afhttprequestoperationmanager *mgr =[Afhttprequestoperationmanager manager]; -Nsmutabledictionary *param =[Nsmutabledictionary dictionary]; -Ysaccount *account =[Ysaccounttool account]; in -param[@"Access_token"] =Account.access_token; to //param[@ "Count"] = @99; +[Mgr GET:@"Https://api.weibo.com/2/statuses/home_timeline.json"Parameters:param success:^ (Afhttprequestoperation *operation,IDresponseobject) { -Nsarray *dictarray = responseobject[@"statuses"]; the * //Advanced Technology-Runtime. Dictionary to Model $Self.statuses =[Ysstatus Mj_objectarraywithkeyvaluesarray:dictarray];Panax Notoginseng [Self.tableview Reloaddata]; -} failure:^ (Afhttprequestoperation *operation, Nserror *error) { the + }]; A}
1 ////2 ////YSStatus.h3 ////Ysweibo4 ////5 ////Created by Ys on 15/12/3.6 ////Copyright (c) 2015 Ys. All rights reserved.7 ////8 //9 //#import <Foundation/Foundation.h>Ten //@class Ysuser; One //@interface Ysstatus:nsobject A ///** - //* Content of Weibo (text) - // */ the //@property (nonatomic, copy) NSString *text; - ///** - //* The source of Weibo - // */ + //@property (nonatomic, copy) NSString *source; - ///** + //* Weibo ID A // */ at //@property (nonatomic, copy) NSString *idstr; - ///** - //* The number of tweets forwarded - // */ - //@property (nonatomic, assign) int reposts_count; - ///** in //* Number of comments on Weibo - // */ to //@property (nonatomic, assign) int comments_count; + ///** - //* Author of Weibo the // */ * //@property (nonatomic, strong) Ysuser *user; $ //@endPanax Notoginseng #import "YSStatus.h" - @implementationYsstatus the + @end
1 ////2 ////YSUser.h3 ////Ysweibo4 ////5 ////Created by Ys on 15/12/3.6 ////Copyright (c) 2015 Ys. All rights reserved.7 ////8 //9 //#import <Foundation/Foundation.h>Ten // One //@interface Ysuser:nsobject A ///** - //* User's ID - // */ the //@property (nonatomic, copy) NSString *idstr; - ///** - //* User's nickname - // */ + //@property (nonatomic, copy) NSString *name; - ///** + //* User's Avatar A // */ at //@property (nonatomic, copy) NSString *profile_image_url; - //@end - - #import "YSUser.h" - - @implementationYsuser in - @end
Three methods of dictionary to model three: Mjextension Automatic dictionary model Mutual Transfer