//收藏數據讀取 與更新
- (void)replaceCurrentViewData :(NSMutableArray *)array
{
DWUser *loginUser = ((AppDelegate* )[UIApplication sharedApplication].delegate).appUser;
NSMutableDictionary *tempDic= [NSKeyedUnarchiver unarchiveObjectWithData:[NSData dataWithContentsOfFile:[Utils applicationDocumentsDirectory:kCollectFilePath]]];
[tempDic setObject:array forKey:loginUser.username];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:tempDic];
[data writeToFile:[Utils applicationDocumentsDirectory:kCollectFilePath] atomically:YES];
}
沙盒路徑的獲取
+(NSString *)applicationDocumentsDirectory :(NSString*)filename
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDirectory,
YES);
NSString *basePath = ([paths count] >0)?[paths objectAtIndex:0]:nil;
NSString *appendPath = filename;
return [basePath stringByAppendingPathComponent:appendPath];
}