2011-12-09 6 views
2

iOS 5.0.1を実行しているiPhone 4では、Wi-Fiと携帯電話の両方でSqlite3データベースが接続されていません。この理由のため、私のアプリはiTunesのApple Storeで4回拒否されました。 iPhone 3.2 iOS 4.1を使用してXcode 3.2.4を使用しています。このアプリはうまく動作しています。iOS 5.0.1を実行しているiPhone 4にSqlite3データベースが接続されていません。

私は、これは

/// @ AppDelegate.m file 

-(void)createDatabaseIfNeeded { 

BOOL success; 
NSError *error; 

//FileManager - Object allows easy access to the File System. 
NSFileManager *FileManager = [NSFileManager defaultManager]; 

//Get the complete users document directory path. 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

//Get the first path in the array. 
NSString *documentsDirectory = [paths objectAtIndex:0]; 


//Create the complete path to the database file. 
NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"passmanager.sqlite"]; 

//Check if the file exists or not. 
success = [FileManager fileExistsAtPath:databasePath]; 

//If the database is present then quit. 
if(success) return; 

//the database does not exists, so we will copy it to the users document directory] 
NSString *dbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"passmanager.sqlite"]; 

//Copy the database file to the users document directory. 
success = [FileManager copyItemAtPath:dbPath toPath:databasePath error:&error]; 

//If the above operation is not a success then display a message. 
//Error message can be seen in the debugger's console window. 
if(!success) 
    NSAssert1(0, @"Failed to copy the database. Error: %@.", [error localizedDescription]); 
} 


-(void)applicationDidFinishLaunching:(UIApplication *)application{ 

// createDatabaseIfNeeded method for first time to create database in new iPhone 
[self createDatabaseIfNeeded]; 
[window addSubview:navigationController.view]; 
[window makeKeyAndVisible]; 

} 

codes-書き込みエラーがありません一部のViewControllerページ

// @ viewController.m 

sqlite3 *database; 

int result = sqlite3_open("passmanager.sqlite", &database); 

if(result != SQLITE_OK){ 
sqlite3_close(database); 
UIAlertView *alert = 
[[UIAlertView alloc] initWithTitle:@"Database Connected" 
         message:@"No" 
         delegate:self 
        cancelButtonTitle:@"OK" 
        otherButtonTitles:nil]; 

[alert show];  
[alert release];    
} 
else{ 
    // some stuff 
} 

Appleは、条件がtrueの場合は、「データベース接続などと訴えたびにコードにアップルにaccrodingいます" 私のシステムでは、他の部分は実行中です。 私を助けてください。高度なThax。開こうとしているデータベースのパスが不完全であるように見えます

答えて

3

それは私がパスを変更したときに、このコードが動作するそうあなたがcreateDatabaseIfNeeded

+0

に設定したものであるとして、それは

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"passmanager.sqlite"]; int result = sqlite3_open([databasePath UTF8String], &database); 

する必要がありますデータベースのフルパスとしてviewController.mファイル。あなたのアプリが承認されていただきありがとうございます。 iTunesのManagePasswordを参照してください。 – dayitv89

関連する問題