开发者

Download and store file on iphone

开发者 https://www.devze.com 2022-12-13 05:09 出处:网络
i want to replace my sqlite DB stores on iphone by a sqlite whic开发者_StackOverflow中文版h is on my server for an update.

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消