#pragma mark -存儲(chǔ)數(shù)據(jù)
-(void)SaveString:(NSString*)UrlStr
{
// 1.獲得沙盒根路徑
NSString*home =NSHomeDirectory();
// 2.document路徑
NSString*docPath = [homestringByAppendingPathComponent:@"Documents"];
NSArray*data =@[UrlStr];
NSString*filepath = [docPathstringByAppendingPathComponent:@"data.plist"];
[datawriteToFile:filepathatomically:YES];
}
讀取數(shù)據(jù)
- (NSArray*)readData {
// 1.獲得沙盒根路徑
NSString*home =NSHomeDirectory();
// 2.document路徑
NSString*docPath = [homestringByAppendingPathComponent:@"Documents"];
// 3.文件路徑
NSString*filepath = [docPathstringByAppendingPathComponent:@"data.plist"];
// 4.讀取數(shù)據(jù)
NSArray*data = [NSArrayarrayWithContentsOfFile:filepath];
returndata;
}
刪除數(shù)據(jù)
NSString *home = NSHomeDirectory();
// 2.document路徑
NSString *docPath = [home stringByAppendingPathComponent:@"Documents"];
NSFileManager * fileManager = [[NSFileManager alloc]init];
[fileManager removeItemAtPath:docPath error:nil];