GiGaMaskTime/GIGA/Common/GiGaNetTool/GiGaAPIResult.m

50 lines
1.0 KiB
Objective-C

//
// GiGaAPIResult.m
// GIGA
//
// Created by lianxiang on 2018/8/15.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiGaAPIResult.h"
@implementation GiGaAPIResult
-(BOOL)success{
return self.code == 0? YES : NO;
}
-(id)initWithDictionary:(NSDictionary *)dic
{
if (self = [super init]) {
@try {
if (dic && ![dic isKindOfClass:[NSNull class]]) {
self.code = [[dic objectForKey:@"code"] integerValue];
self.message = [dic objectForKey:@"msg"];
// NSDictionary *data = [[dic objectForKey:@"result"] objectForKey:@"data"];
self.dic = dic;
}else{
self.message = @"请求异常";
self.dic = nil;
self.code = -1;
}
}
@catch(NSException *exception) {
self.dic = dic;
self.code = -1;
}
@finally {
}
}
return self;
}
@end