나름 프로그래밍?/ Objective-C

파일 존재 여부 검사

-Dong- 2012. 5. 9. 21:24



  파일경로는 간단하게..


  [[NSBundle mainBundle] pathForResource:@"aps" ofType:@"cer"];

  위 경로를 받아서 아래와 같이 검사

BOOL fileExists
= [[NSFileManager defaultManager] fileExistsAtPath:somePath];




ex>


    NSString *filePath =  [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"];
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
   
    if (fileExists) {
        NSLog(@"Exist");
    }else {
        NSLog(@"Not Exist");
    }