我想从我的iPhone应用程序中删除图像.
我使用下面的方法,将图像的名称作为参数传递.
我使用下面的方法,将图像的名称作为参数传递.
问题是图像不会被删除.
- (void)removeImage:(NSString*)fileName { NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullPath = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.png",fileName]]; [fileManager removeItemAtPath: fullPath error:NULL]; NSLog(@"image removed: %@",fullPath); NSString *appFolderPath = [[NSBundle mainBundle] resourcePath]; NSLog(@"Directory Contents:\n%@",[fileManager directoryContentsAtPath: appFolderPath]); }