Usuń określony plik z katalogu dokumentów
Chcę usunąć obraz z katalogu dokumentów aplikacji. Kod, który napisałem, aby usunąć obraz, to:
-(void)removeImage:(NSString *)fileName
{
fileManager = [NSFileManager defaultManager];
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsPath = [paths objectAtIndex:0];
filePath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", fileName]];
[fileManager removeItemAtPath:filePath error:NULL];
UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[removeSuccessFulAlert show];
}
Działa częściowo. Ten kod usuwa plik z katalogu, ale gdy sprawdzam zawartość katalogu, nadal wyświetla tam nazwę obrazu. Chcę całkowicie usunąć ten plik z katalogu. Co powinienem zmienić w kodzie, aby zrobić to samo? Dzięki