iphone序列化资料

网友分享于:2015-09-23 16:51 发表在 Iphone
iphone序列化文件
#pragma -
#pragma 序列化列表
+ (BOOL)saveMatchListToFile:(NSArray*)newMathcList {
    NSString *mathcListFile = [[PlayViewController getLocalMatchList] stringByAppendingFormat:@"matchList.arch", nil];
    return [NSKeyedArchiver archiveRootObject:newMathcList toFile:mathcListFile];
}

+ (NSMutableArray*)getMatchListFromFile {
    NSString *matchListFile = [[PlayViewController getLocalMatchList] stringByAppendingFormat:@"matchList.arch", nil];
    return [NSKeyedUnarchiver unarchiveObjectWithFile:matchListFile];
}

+ (NSString*)getLocalMatchList {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   
    NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"tdata"];
   
    BOOL isDirectory = YES;
    if (![[NSFileManager defaultManager] fileExistsAtPath:documentsDirectory isDirectory:&isDirectory]) {
        NSError *error = nil;
        [[NSFileManager defaultManager] createDirectoryAtPath:documentsDirectory withIntermediateDirectories:YES attributes:nil error:&error];
        if (error) {
            NSLog(@"------ create directory error : %@", error);
        }
    }
   
    return documentsDirectory;
}

推荐分类: 移动开发 Android Iphone Windows Mobile Symbian BlackBerry QT开发 Brew MeeGo 移动平台 移动软件开发 电信IT应用开发 移动应用
推荐标签: php websocket input navicat finereport
相关文章
最新发表
热门推荐