//
|
// Global.m
|
// airtree
|
//
|
// Created by WindShan on 2016/11/14.
|
// Copyright © 2016年 Gloria. All rights reserved.
|
//
|
|
#import "Global.h"
|
|
@implementation Global
|
|
|
NSMutableDictionary * _loginUser;
|
DeviceSpareModel * _selectedDevice;
|
NSString * _curDeviceName;
|
Room * _sel_room;
|
int _curPage;
|
BOOL _bConnectSuccess;
|
NSString * _curReceiveHexValue;
|
|
+ (Global *)global
|
{
|
static Global *s_global = nil;
|
static dispatch_once_t onceToken;
|
dispatch_once(&onceToken, ^{
|
s_global = [[Global alloc] init];
|
});
|
|
return s_global;
|
}
|
|
+(void)setCurrentDevice:(DeviceSpareModel*) device
|
{
|
_selectedDevice = device;
|
}
|
|
+ (BOOL)isSystemLowIOS11
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer - IOSBaseVersion11 < -0.001) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (BOOL)isSystemLowIOS10
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer - IOSBaseVersion10 < -0.001) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (BOOL)isSystemLowIOS9
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer - IOSBaseVersion9 < -0.001) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (BOOL)isSystemLowIOS8
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer - IOSBaseVersion8 < -0.001) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (BOOL)isSystemLowIOS7
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer - IOSBaseVersion7 < -0.001) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (BOOL)isSystemLowiOS6
|
{
|
UIDevice *device = [UIDevice currentDevice];
|
CGFloat systemVer = [[device systemVersion] floatValue];
|
if (systemVer < IOSBaseVersion6) {
|
return YES;
|
}
|
|
return NO;
|
}
|
|
+ (NSString *)clientVersion
|
{
|
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
return [infoDict objectForKey:@"CFBundleShortVersionString"];
|
}
|
|
+(BOOL)isEmptyObject:(id)object
|
{
|
if (object == nil || object == NULL) {
|
return YES;
|
}
|
if ([object isKindOfClass:[NSNull class]]) {
|
return YES;
|
}
|
return NO;
|
}
|
|
|
|
+ (BOOL) isBlankString:(NSString *)string {
|
|
if (string == nil || string == NULL) {
|
|
return YES;
|
|
}
|
|
if ([string isKindOfClass:[NSNull class]]) {
|
|
return YES;
|
|
}
|
|
if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
|
|
return YES;
|
|
}
|
|
return NO;
|
|
}
|
|
|
#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
|
{
|
|
//NSMutableDictionary *returnDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:error];
|
|
if(responseBody != nil)
|
{
|
BaseResModel *model = [[BaseResModel alloc] init];
|
NSMutableDictionary * data = [responseBody objectForKey:@"data"];
|
|
if( data.count == 0 )
|
{
|
model.desc = [responseBody objectForKey:@"msg"];
|
model.code = -1;
|
}
|
else
|
{
|
if ([[data allKeys] containsObject:@"code"])
|
{
|
model.code = [[data objectForKey:@"code"] intValue];
|
}
|
else
|
{
|
model.code = -1;
|
}
|
|
model.desc = [data objectForKey:@"msg"];
|
model.content = [data objectForKey:@"info"];
|
}
|
|
return model;
|
}
|
else
|
{
|
return nil;
|
}
|
}
|
|
|
@end
|