我有一个充满用户名和密码等的数据库。但是我需要能够在每次用户打开应用程序时下载数据库的新副本,或者更好的是,使用互联网读/写数据库,这是最实用的解决方案。
这是目前我用来在本地读取和写入数据库的代码,这主要是为了创建将用于在线读取/写入数据库的函数和规则。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
databaseName = @"UserDatabase.sql";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
[self readNamesFromDatabase];
// Query the database for all username,pass,email records and construct the three different array's for each.
[registerForm setHidden:YES];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
return YES;
}
先感谢您!