i want to replace my sqlite DB stores on iphone by a sqlite whic开发者_StackOverflow中文版h is on my server for an update. how could i do that? i can download it and get it with an NSData object but how do i store it on the iphone and then replace the old one ? thanks
That's pretty simple. It should just be something like this:
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];
精彩评论