iOS6 で Cordova 2.7 に次のプラグインを使用しましたが、1 日前に更新されたばかりです。https://github.com/pgsqlite/PG-SQLitePlugin-iOS
ここにもAndroidバージョンがあります。問題の一部は、PhoneGap の変更であるため、プラグインを最新の状態に保つのに時間がかかり、失効することがよくあります。このプロジェクトで使用する AppDelegate.m の init メソッドのコードは次のとおりですhttp://www.binpress.com/app/conference-core-ios-for-phonegap/1483
アプリケーションに関連するファイルをリロードするために、iOS シミュレーターをワイプする必要がある場合があることに注意してください。
- (id)init{
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
__has_feature(objc_arc) の場合
NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
そうしないと
NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
終了
[NSURLCache setSharedURLCache:sharedCache];
databaseName = @"SomeCoolDatabase.db";
NSLog(@"databaseName: %@", databaseName);
databasePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSLog(@"databasePath: %@", databasePath);
databaseFile = [databasePath stringByAppendingPathComponent:databaseName];
NSLog(@"databaseFile: %@", databaseFile);
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
self = [super init];
return self;
}
-(void)checkAndCreateDatabase {
// Check if the SQL database has already been saved to the users phone, if not then copy it over
BOOL success;
// Create a FileManager object, we will use this to check the status
// of the database and to copy it over if required
NSFileManager *fileManager = [NSFileManager defaultManager];
// Check if the database has already been created in the users filesystem
success = [fileManager fileExistsAtPath:databaseFile];
// If the database already exists then return without doing anything
if(success){
NSLog(@"Database Present");
return;
} else {
NSLog(@"database not present");
}
// If not then proceed to copy the database from the application to the users filesystem
// Get the path to the database in the application package
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
// Create the database folder structure
[fileManager createDirectoryAtPath:databasePath withIntermediateDirectories:YES attributes:nil error:NULL];
// Copy the database from the package to the users filesystem
[fileManager copyItemAtPath:databasePathFromApp toPath:databaseFile error:nil];
[fileManager release];
}
お役に立てれば...