Files
mier_ios/SweetParty/Expand/UserData/MLRoomInformationModel.m

98 lines
3.3 KiB
Mathematica
Raw Permalink Normal View History

2025-08-11 10:43:19 +08:00
//
// MLRoomInformationModel.m
// MoHuanXingYu
//
// Created by aa on 2019/6/14.
// Copyright © 2019 MoHuanXingYu. All rights reserved.
//
#import "MLRoomInformationModel.h"
#import <MJExtension.h>
@implementation MLRoomInformationModel
+(instancetype)currentAccount{
static MLRoomInformationModel *account;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!account) {
account = [[MLRoomInformationModel alloc] init];
account.isBanned = YES;
}
});
return account;
}
@end
@implementation MLRoomInformationManager
+ (BOOL)saveUserInfo:(MLRoomInformationModel *)dic
{
return [NSKeyedArchiver archiveRootObject:[dic mj_keyValues] toFile:[self path]];
}
+ (MLRoomInformationModel *)userInfo
{
id data = [NSKeyedUnarchiver unarchiveObjectWithFile:[self path]];
MLRoomInformationModel *model = [MLRoomInformationModel mj_objectWithKeyValues:data];
model.isBanned = YES;
return model;
}
+ (BOOL)clearUserInfo
{
NSFileManager *defaultManager = [NSFileManager defaultManager];
if ([defaultManager isDeletableFileAtPath:[self path]])
{
//
return [defaultManager removeItemAtPath:[self path] error:nil];
}
else
{
return NO;
}
}
/**
Documents/ ()iTunes
Library,CachesiTunes.
Library/Caches: 使()iTunes
Library/Preferences: NSUserDefaultsplistiTunes
@return <#return value description#>
*/
+(NSString *)path
{
//
// NSString *homeDir = NSHomeDirectory();
// // Documents
// NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) firstObject];
// //Library
// NSString *libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) lastObject];
// // cache
// NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) firstObject];
// // tmp
NSString *tmpDir = NSTemporaryDirectory();
// //
// NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *name = @"MLRoomInformationModel";
NSString *type = @"sql";
NSString *allName = [NSString stringWithFormat:@"%@.%@",name,type];
return [tmpDir stringByAppendingPathComponent:allName];;
}
@end