New file |
| | |
| | | // |
| | | // Global.m |
| | | // airtree |
| | | // |
| | | // Created by WindShan on 2016/11/14. |
| | | // Copyright © 2016年 Gloria. All rights reserved. |
| | | // |
| | | |
| | | #import "Global.h" |
| | | |
| | | @implementation Global |
| | | |
| | | + (Global *)global |
| | | { |
| | | static Global *s_global = nil; |
| | | static dispatch_once_t onceToken; |
| | | dispatch_once(&onceToken, ^{ |
| | | s_global = [[Global alloc] init]; |
| | | }); |
| | | |
| | | return s_global; |
| | | } |
| | | |
| | | |
| | | #pragma mark - 系统提示 |
| | | |
| | | + (void)alertMessage:(NSString *)message |
| | | { |
| | | [Global alertMessageEx:message |
| | | title:nil |
| | | okTtitle:@"确定" |
| | | cancelTitle:nil |
| | | delegate:nil]; |
| | | } |
| | | |
| | | + (void)alertMessageEx:(NSString *)message |
| | | title:(NSString *)title |
| | | okTtitle:(NSString *)okTitle |
| | | cancelTitle:(NSString *)cancelTitle |
| | | delegate:(id)delegate |
| | | { |
| | | UIAlertView *alertView = [[UIAlertView alloc] |
| | | initWithTitle:title |
| | | message:message |
| | | delegate:delegate |
| | | cancelButtonTitle:cancelTitle |
| | | otherButtonTitles:okTitle, |
| | | nil]; |
| | | |
| | | [alertView show]; |
| | | } |
| | | |
| | | |
| | | +(BaseResModel *)toBaseModel:(id) responseBody |
| | | { |
| | | if(!TWIsEmpty(responseBody)) |
| | | { |
| | | BaseResModel *model = [[BaseResModel alloc] init]; |
| | | |
| | | if ([[responseBody allKeys] containsObject:@"code"]) |
| | | { |
| | | model.code = [[responseBody objectForKey:@"code"] intValue]; |
| | | } |
| | | else |
| | | { |
| | | model.code = -1; |
| | | } |
| | | |
| | | model.desc = [responseBody objectForKey:@"message"]; |
| | | model.content = [responseBody objectForKey:@"data"]; |
| | | |
| | | return model; |
| | | } |
| | | else |
| | | { |
| | | return nil; |
| | | } |
| | | } |
| | | @end |