Tools.m
1.27 KB
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
//
// Tools.m
// CNLiveUserSystemDemo
//
// Created by iOS on 16/9/18.
// Copyright © 2016年 zhulin. All rights reserved.
//
#import "Tools.h"
@implementation Tools
#pragma mark 验证用户是否登录
+ (BOOL)isLogin
{
return [[NSUserDefaults standardUserDefaults] boolForKey:@"login"];
}
#pragma mark 设置登录状态
+ (void)setUserLogin:(BOOL)isLogin
{
[[NSUserDefaults standardUserDefaults] setBool:isLogin forKey:@"login"];
}
+ (NSDictionary *)getLocalUserInfo
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *userInfoDic = [userDefaults objectForKey:UserInfoKey];
return userInfoDic;
}
#pragma mark - alertView
+ (void)toast:(NSString *)message
{
UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil, nil];
[toast show];
double duration = 2.5;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[toast dismissWithClickedButtonIndex:0 animated:NO];
});
}
@end