// // GlobalData.m // ChinaDream // // Created by zhangfeng on 12-11-26. // Copyright (c) 2012年 eastedge. All rights reserved. // #import "GlobalData.h" UINavigationController *GB_Nav = nil; //int GB_OpenWaitShowCount = 0; //float GB_StartYCoordinate = 0.0f; @implementation GlobalData @synthesize GB_Key = _GB_Key; @synthesize GB_UserModel = _GB_UserModel; //@synthesize GB_CompanyModel = _GB_CompanyModel; //@synthesize GB_MarketModules = _GB_MarketModules; #pragma mark 实现单例 SYNTHESIZE_SINGLETONE_FOR_CLASS(GlobalData); - (instancetype)init{ self = [super init]; if (self) { //初始化状态栏 self.statusBarStyle = UIStatusBarStyleLightContent; } return self; } #pragma mark lazy init //set get key - (void)setGB_Key:(NSString *)GB_Key{ [GlobalMethod writeStr:GB_Key!=nil?GB_Key:@"" forKey:LOCAL_KEY]; _GB_Key = GB_Key; } - (NSString*)GB_Key{ if (!isStr(_GB_Key)){ _GB_Key = [GlobalMethod readStrFromUser:LOCAL_KEY]; } return _GB_Key; } //set get userModel - (void)setGB_UserModel:(ModelUser *)GB_UserModel{ [GlobalMethod writeStr:GB_UserModel != nil?[GlobalMethod exchangeModelToJson:GB_UserModel]:@"" forKey:LOCAL_USERMODEL]; _GB_UserModel = GB_UserModel; //保存手机号 if (isStr(GB_UserModel.phone)) { NSUserDefaults * user = [NSUserDefaults standardUserDefaults]; [user setObject:GB_UserModel.phone forKey:LOCAL_PHONE]; [user synchronize]; } if (GB_UserModel) { [[NSNotificationCenter defaultCenter]postNotificationName:NOTICE_SELFMODEL_CHANGE object:nil]; } } + (void)saveUserModel{ [GlobalData sharedInstance].GB_UserModel = [GlobalData sharedInstance].GB_UserModel; } - (ModelUser *)GB_UserModel{ if (_GB_UserModel.phone == 0) { NSDictionary * dicItem = [GlobalMethod exchangeStringToDic:[GlobalMethod readStrFromUser:LOCAL_USERMODEL]]; _GB_UserModel = [ModelUser modelObjectWithDictionary:dicItem]; } return _GB_UserModel; } //set Notice View - (NoticeView *)GB_NoticeView{ if (_GB_NoticeView == nil) { _GB_NoticeView = [NoticeView new]; } return _GB_NoticeView; } @end