Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active July 3, 2021 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/c3dde9759b1e61487c7ed5113df22501 to your computer and use it in GitHub Desktop.
Save baobao/c3dde9759b1e61487c7ed5113df22501 to your computer and use it in GitHub Desktop.
// 【1. ファイルまでのパスを作成】
// ダウンロードした画像が格納されたディレクトリパス取得(適宜変更してください)
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// ファイルパスの作成
NSString *filePath = [[dirPaths objectAtIndex:0] stringByAppendingPathComponent:@"img.png"];
// 【2. NSFileManagerを取得】
NSFileManager *fileManager = [NSFileManager defaultManager];
// 【3. NSFileManagerのfileExistsAtPathメソッドを実行】
// fileExistsAtPathメソッドでファイルの有無確認
BOOL isExist = [fileManager fileExistsAtPath:filePath];
// 1が出力されたら存在する
NSLog(@"isExist: %d", isExist);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment