| | |
| | | |
| | | @implementation ResponseData |
| | | |
| | | |
| | | /// Description |
| | | - (BOOL)success |
| | | { |
| | | //河东code为0 ,萤石为200 代表成功 |
| | | return [self.code isEqual: @"0"] || [self.code isEqual: @"200"] ; |
| | | } |
| | | |
| | | |
| | | /// 解析返回字典参数 |
| | | /// @param dic 返回参数 |
| | | - (id)initWithDictionary:(NSDictionary *)dic |
| | | { |
| | | if (self = [super init]) { |
| | | @try { |
| | | if (dic) { |
| | | //1.取出返回数据的状态码 |
| | | self.code = [NSString stringWithFormat:@"%@", dic[@"code"]]; |
| | | //2.提示信息 |
| | | self.message = [dic objectForKey:@"message"]; |
| | | //3.返回数据 |
| | | NSDictionary *mData = (NSDictionary *)[dic objectForKey:@"data"]; |
| | | self.data = mData; |
| | | } else { |
| | | //没有返回数据 |
| | | self.message = @"网络错误"; |
| | | self.data = nil; |
| | | self.code = @"-2"; |
| | | } |
| | | } |
| | | //接收到异常 |
| | | @catch (NSException *exception) { |
| | | self.data = dic; |
| | | self.code = @"-1"; |
| | | } |
| | | @finally { |
| | | |
| | | } |
| | | } |
| | | return self; |
| | | } |
| | | @end |