macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

removeFileAtPath:error:

指定したパスのファイルを削除します
-(BOOL)removeFileAtPath:(NSString *)path:
             error:(NSError *)error:

解説

指定したパス(path)のファイルを削除します。削除できればYESを返します。

返り値

( BOOL )

YES/NO

引数

( NSString * )path

パス

(NSError * )error

ハンドラ

クラス

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