BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"TESTDB.sqlite"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"TESTDB.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
'iPhone' 카테고리의 다른 글
NSString 자주 쓰는 함수 (0) | 2011.08.22 |
---|---|
UIImageView URL로 로드하기 (0) | 2011.08.22 |
어디서든 키보드 감추기 (0) | 2011.08.22 |
하위뷰에서 상위뷰 컨트롤 하는 방법 (0) | 2011.08.22 |
원하는 문자만 입력 받기 (0) | 2011.08.22 |