添加这些methods
以在store temporary data
进入Temp Directory
和retrieve
离开时使用
#pragma mark
#pragma mark Data Save
// need a path
- (NSString *)getArrayPath
{
//NSString* path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
return [NSTemporaryDirectory() stringByAppendingPathComponent:@"temp.dat"];
}
// save an array
- (void)saveVideoData:(NSMutableArray*)data
{
[NSKeyedArchiver archiveRootObject:data toFile:[self getArrayPath]];
}
// get that array back
- (NSMutableArray *)loadSavedData
{
return [NSKeyedUnarchiver unarchiveObjectWithFile:[self getArrayPath]];
}
保存值:例如。
//create array
NSMutableArray *arrValues = [NSMutableArray arrayWithObjects:txt1.text,txt2.text,txt3.text,nil];
[self saveVideoData:arrValues];
获取值:例如。
NSMutableArray *arrValues = [self loadSavedData];
通过在你中添加上述方法也another view controller
可以得到data values
there
。