读书人

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

发布时间: 2012-08-11 20:50:31 作者: rapoo

将数据(数组)储存到.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);

}

读书人网 >移动开发

热点推荐