私はsqlite dbを開きたいのですが、それは私のmainBundleにはありませんが、サーバーにはありません。
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"info.sqlite"];
しかし、私は持っています
NSString *filePath = @"http://serverAddress/info.sqlite";
NSURL *url = [NSURL URLWithString:filePath];
NSData *myData = [NSData dataWithContentsOfURL:url];
そして、このデータベースを読んだら何ができるでしょうか? 私のデータベースがmainBundle内にある場合、私はこれを行います:
if (sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) {
const char *sql = "select id, one, two from TABLE";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
idNum = [NSNumber numberWithInt:(int)sqlite3_column_int(selectstmt, 0)];
...
...
しかし、NSData があるとしたら? 手伝って頂けますか?