forked from BigShow1949/BigShow1949
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62b210b
commit 9826ed2
Showing
53 changed files
with
5,294 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+5.15 KB
(110%)
BigShow1949.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/HomeModel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// HomeModel.h | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface HomeModel : NSObject | ||
|
||
@property (nonatomic,assign)NSInteger count; | ||
@property (nonatomic,assign)NSInteger start; | ||
@property (nonatomic,assign)NSInteger total; | ||
@property (nonatomic,assign)NSArray *books; | ||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/HomeModel.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// HomeModel.m | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import "HomeModel.h" | ||
|
||
@implementation HomeModel | ||
|
||
@end |
15 changes: 15 additions & 0 deletions
15
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/HomePresenter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// HomePresenter.h | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import "HttpPresenter.h" | ||
#import "HomeViewProtocol.h" | ||
|
||
@interface HomePresenter : HttpPresenter <id<HomeViewProtocol>> | ||
|
||
- (void)getMovieListWithUrlString:(NSString *)urlString; | ||
@end |
38 changes: 38 additions & 0 deletions
38
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/HomePresenter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// HomePresenter.m | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import "HomePresenter.h" | ||
#import "HomeModel.h" | ||
|
||
#import "YYModel.h" | ||
|
||
@interface HomePresenter() | ||
|
||
@end | ||
|
||
@implementation HomePresenter | ||
|
||
- (void)getMovieListWithUrlString:(NSString *)urlString{ | ||
[self.httpClient get:urlString parameters:nil]; | ||
} | ||
#pragma mark - HttpResponseHandle | ||
|
||
- (void)onSuccess:(id)responseObject{ | ||
// 这里崩溃了 | ||
HomeModel *model = [HomeModel yy_modelWithJSON:responseObject]; | ||
if ([_view respondsToSelector:@selector(onGetMovieListSuccess:)]) { | ||
[_view onGetMovieListSuccess:model]; | ||
} | ||
} | ||
|
||
- (void)onFail:(id)clientInfo errCode:(NSInteger)errCode errInfo:(NSString *)errInfo{ | ||
if ([_view respondsToSelector: @selector(onGetMovieListFail: des:)]) { | ||
[_view onGetMovieListFail:errCode des:errInfo]; | ||
} | ||
} | ||
@end |
17 changes: 17 additions & 0 deletions
17
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/HomeViewProtocol.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// HomeViewProtocol.h | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "HomeModel.h" | ||
|
||
@protocol HomeViewProtocol <NSObject> | ||
- (void)onGetMovieListSuccess:(HomeModel *)homeModel; | ||
|
||
- (void)onGetMovieListFail:(NSInteger) errorCode des:(NSString *)des; | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/MVPHomeViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// MVPHomeViewController.h | ||
// BigShow1949 | ||
// | ||
// Created by apple on 17/8/11. | ||
// Copyright © 2017年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface MVPHomeViewController : UIViewController | ||
|
||
@end |
48 changes: 48 additions & 0 deletions
48
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/MVPHomeViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// MVPHomeViewController.m | ||
// BigShow1949 | ||
// | ||
// Created by apple on 17/8/11. | ||
// Copyright © 2017年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "MVPHomeViewController.h" | ||
#import "HomePresenter.h" | ||
#import "HomeViewProtocol.h" | ||
|
||
@interface MVPHomeViewController ()<HomeViewProtocol> | ||
@property (nonatomic,strong)HomePresenter *homePresenter; | ||
@end | ||
|
||
@implementation MVPHomeViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
self.view.backgroundColor = [UIColor whiteColor]; | ||
[self setupData]; | ||
} | ||
- (void)setupData{ | ||
/* | ||
http://www.jianshu.com/p/abea207c23e7# | ||
*/ | ||
_homePresenter = [[HomePresenter alloc] initWithView:self]; | ||
[_homePresenter getMovieListWithUrlString:@"https://api.douban.com/v2/book/search?count=20&q=iOS"]; | ||
} | ||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
#pragma mark - HomeViewProtocol | ||
|
||
- (void)onGetMovieListSuccess:(HomeModel *)homeModel{ | ||
|
||
UIAlertController *alertCtl = [UIAlertController alertControllerWithTitle:@"result" message:@"request success" preferredStyle:UIAlertControllerStyleActionSheet]; | ||
[self presentViewController:alertCtl animated:YES completion:nil]; | ||
} | ||
|
||
- (void)onGetMovieListFail:(NSInteger)errorCode des:(NSString *)des{ | ||
UIAlertController *alertCtl = [UIAlertController alertControllerWithTitle:@"result" message:@"request fail" preferredStyle:UIAlertControllerStyleActionSheet]; | ||
[self presentViewController:alertCtl animated:YES completion:nil]; | ||
} | ||
@end |
19 changes: 19 additions & 0 deletions
19
BigShow1949/Classes/12 - DesignPattern(设计模式)/MVP_Home/net/HttpClient.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// HttpClient.h | ||
// MVP | ||
// | ||
// Created by baoshan on 17/2/8. | ||
// Copyright © 2017年 hans. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@protocol HttpResponseHandle; | ||
|
||
@interface HttpClient : NSObject | ||
|
||
//初始化方法 | ||
- (instancetype)initWithHandle:(id<HttpResponseHandle>) responseHandle; | ||
- (void)post:(NSString *)URLString parameters:(id)parameters; | ||
- (void)get:(NSString *)URLString parameters:(id)parameters; | ||
@end |
Oops, something went wrong.