首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

将数据(数组)存储到.plist文件中

2012-08-11 
将数据(数组)储存到.plist文件中-(NSString *)getRecordFilePath{ NSArray *paths NSSearchPathForDirect

将数据(数组)储存到.plist文件中

-(NSString *)getRecordFilePath{

 NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

 NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *path = [documentsDirectory stringByAppendingPathComponent:@"test.plist"];

return path;

}

-(NSMutableArray *)readLevelData{

NSString * filePath=[selfgetRecordFilePath];

//    NSLog(@"this is filePath : %@",filePath);

self.myInfo_array=[NSKeyedUnarchiverunarchiveObjectWithFile:filePath];

if (!myInfo_array) {

[selfsetDate];

}

return myInfo_array;

}

-(void)saveLevelData {

NSString *path = [selfgetRecordFilePath];

BOOL boo=[NSKeyedArchiverarchiveRootObject:self.myInfo_arraytoFile:path];

NSLog(@"储存 bool : %d",boo);

}

热点排行