2009-11-28 10 views
1

iphone에 sqlite DB 상점을 sqlite로 대체하여 내 서버에 업데이트하고 싶습니다. 어떻게 할 수 있습니까? 내가 그것을 다운로드하고 NSData 개체와 함께 얻을 수 있지만 아이폰에 저장하고 이전 하나를 대체합니까? 감사합니다.iphone에 파일 다운로드 및 저장

답변

3

매우 간단합니다. 다음과 같이되어야합니다.

NSData *fetchedData = ...; /* downloaded using NSURLConnection or whatever*/ 
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"DBName.sqlite"]; 

[fetchedData writeToFile:filePath atomically:YES]; 
관련 문제