본문 바로가기

Development/IOS & Mac

NSFileManager - the operation couldn t be completed cocoa error 4


the operation couldn t be completed cocoa error 4 에러와 함께 복사가 되지 않았다. 원인은 파일 경로 상에서 폴더가 있는데 그 폴더를 생성하지 않는 것이 원인이였다.


NSString *databasePath = [[NSBundle mainBundle] pathForResource:databaseName ofType:@"sqlite"];

      [fileManger copyItemAtPath:databasePath toPath:dbFilePath error:&error];



아래와 같이 폴더를 생성해주는 코드가 필요하다.~!


 if ([fileManger fileExistsAtPath:[self getDatabaseFolder]]) {

    [fileManger createDirectoryAtPath:[self getDatabaseFolder] withIntermediateDirectories:YES attributes:nil error:nil];

}

'Development > IOS & Mac' 카테고리의 다른 글