Skip to content

Commit

Permalink
Improve Delegate
Browse files Browse the repository at this point in the history
add client codes
  • Loading branch information
wgqzlj committed Aug 8, 2014
1 parent 26acd20 commit e331a1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions YunJieKou.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
@protocol YunJiekouDelegate <NSObject>

@optional
-(void)yunjiekou:(id)yjkObj serverDataGetSuccess:(id)serverData;
-(void)yunjiekou:(id)yjkObj serverDataGetFailure:(id)serverData message:(NSString *)message;

-(void)yunjiekou:(id)yjkObj serverDataGetSuccess:(id)serverData message:(NSString *)message code:(int)code;
-(void)yunjiekou:(id)yjkObj serverDataGetFailure:(id)serverData message:(NSString *)message code:(int)code;


@end

Expand Down
6 changes: 3 additions & 3 deletions YunJieKou.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
if([_delegate respondsToSelector:@selector(yunjiekou:serverDataGetFailure:message:)])
{
[_delegate yunjiekou:self serverDataGetFailure:nil message:@"Network error"];
[_delegate yunjiekou:self serverDataGetFailure:nil message:@"Network Error" code:300000001];
}
}

Expand All @@ -129,12 +129,12 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection{
{
if([_delegate respondsToSelector:@selector(yunjiekou:serverDataGetSuccess:)])
{
[_delegate yunjiekou:self serverDataGetSuccess:[respDic objectForKey:@"data"]];
[_delegate yunjiekou:self serverDataGetSuccess:[respDic objectForKey:@"data"] message:[respDic objectForKey:@"message"] code:[[respDic objectForKey:@"code"] intValue]];
}
}else{
if([_delegate respondsToSelector:@selector(yunjiekou:serverDataGetFailure:message:)])
{
[_delegate yunjiekou:self serverDataGetFailure:nil message:@"Data deserialize failre"];
[_delegate yunjiekou:self serverDataGetFailure:nil message:@"Data Deserialize Failure" code:300000002];
}
}

Expand Down

0 comments on commit e331a1a

Please sign in to comment.