removeFileAtPath:error:
指定したパスのファイルを削除します
-(BOOL)removeFileAtPath:(NSString *)path: error:(NSError *)error:
解説
指定したパス(path)のファイルを削除します。削除できればYESを返します。
返り値
( BOOL )
YES/NO
引数
( NSString * )path
パス
(NSError * )error
ハンドラ
フレームワーク
Foundation
クラス
NSFileManager
Instance Methods
使用可能
10.0
参照
- copyPath:toPath:handler:
- linkPath:toPath:handler:
- movePath:toPath:handler:
- fileManager:shouldProceedAfterError:
- fileManager:willProcessPath:
例文
#import "MyObject.h" //!!!!!!!!注意!!!!!!!!!! //ホームディレクトリのcreatedNewFileというファイルが警告無しに削除されます。 @implementation MyObject - (IBAction)myAction:(id)sender { NSString *str = @"~/"; NSFileManager *myFile = [ NSFileManager defaultManager]; [myFile changeCurrentDirectoryPath:[str stringByExpandingTildeInPath]]; [myFile removeFileAtPath:@"createdNewFile" handler:self]; NSLog([myFile currentDirectoryPath]); } @end