单军华
2018-07-12 3e8437ae559487362fae3525beb79c534c213a51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
//  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