我保存NSDocumentDirectory
這樣:刪除在NSDocumentDirectory
NSLog(@"%@", [info objectAtIndex:i]);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Images%d.png", i]];
ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
//----resize the images
image = [self imageByScalingAndCroppingForSize:image toSize:CGSizeMake(256,256*image.size.height/image.size.width)];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
我知道如何刪除NSDocumentDirectory
所有圖像。
但我想知道如何刪除名稱爲oneSlotImages
的所有圖像。
謝謝
您是否應該在用戶的文檔目錄中刪除文件而不知曉並同意? – trojanfoe 2012-07-12 10:40:34
我保存圖像。然後我想刪除他們和reADDing,更新如。 – Bazinga 2012-07-12 10:42:26
那麼這似乎是合理的,但是[NSData writeToFile:atomically:]'會覆蓋文件,所以不需要先刪除它們。 – trojanfoe 2012-07-12 10:50:33