自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

詳解Sqlite如何在IOS開發(fā)中應(yīng)用

移動(dòng)開發(fā) iOS
Sqlite如何在IOS開發(fā)中應(yīng)用是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)在IOS開發(fā)中sqlite數(shù)據(jù)庫的使用方法,具體內(nèi)容來看本文詳解。

Sqlite如何在IOS開發(fā)中應(yīng)用是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)在IOS開發(fā)sqlite數(shù)據(jù)庫的使用方法。sqlite數(shù)據(jù)庫初始化,復(fù)制到用戶目錄,并判斷是否數(shù)據(jù)庫已經(jīng)存在,或者復(fù)制是否成功!

在AppDelegate.m中輸入以下代碼,以便復(fù)制預(yù)置數(shù)據(jù)庫到指定doucment目錄

  1. - (BOOL) initializeDb {  
  2. NSLog (@"initializeDB");  
  3. // look to see if DB is in known location (~/Documents/$DATABASE_FILE_NAME)  
  4. //START:code.DatabaseShoppingList.findDocumentsDirectory  
  5. NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
  6. NSString *documentFolderPath = [searchPaths objectAtIndex: 0];  
  7. //查看文件目錄  
  8. NSLog(@"%@",documentFolderPath);  
  9. dbFilePath = [documentFolderPath stringByAppendingPathComponent:@"shopping.db"];  
  10. //END:code.DatabaseShoppingList.findDocumentsDirectory  
  11. [dbFilePath retain];  
  12. //START:code.DatabaseShoppingList.copyDatabaseFileToDocuments  
  13. if (! [[NSFileManager defaultManager] fileExistsAtPath: dbFilePath]) {  
  14. // didn't find db, need to copy  
  15. NSString *backupDbPath = [[NSBundle mainBundle] pathForResource:@"shopping" ofType:@"db"];  
  16. if (backupDbPath == nil) {  
  17. // couldn't find backup db to copy, bail  
  18. return NO;  
  19. } else {  
  20. BOOL copiedBackupDb = [[NSFileManager defaultManager] copyItemAtPath:backupDbPath toPath:dbFilePath error:nil];  
  21. if (! copiedBackupDb) {  
  22. // copying backup db failed, bail  
  23. return NO;  
  24. }  
  25. }  
  26. }  
  27. return YES;  
  28. //END:code.DatabaseShoppingList.copyDatabaseFileToDocuments  
  29. NSLog (@"bottom of initializeDb");  
  30. }  
  31. - (void)applicationDidFinishLaunching:(UIApplication *)application {  
  32. // copy the database from the bundle if necessary  
  33. if (! [self initializeDb]) {  
  34. // TODO: alert the user!  
  35. NSLog (@"couldn't init db");  
  36. return;  
  37. }  
  38.     // Add the tab bar controller's current view as a subview of the window  
  39.     [window addSubview:tabBarController.view];  

小結(jié):詳解Sqlite如何在IOS開發(fā)中應(yīng)用的內(nèi)容介紹完了,希望本文能對(duì)你有所幫助!

責(zé)任編輯:zhaolei 來源: 新浪博客
相關(guān)推薦

2011-09-02 19:12:59

IOS應(yīng)用Sqlite數(shù)據(jù)庫

2013-01-06 09:52:43

SQLite

2013-04-09 16:04:06

iOS開發(fā)SQLite知識(shí)總結(jié)

2011-07-27 10:16:41

iPhone SQLite 數(shù)據(jù)庫

2013-05-02 13:06:05

C++遇到iOS應(yīng)用開SQLITE

2013-04-01 10:49:51

iOS開發(fā)sqlite數(shù)據(jù)庫

2011-08-17 14:30:34

iOS開發(fā)窗口

2011-08-17 14:20:21

IOS開發(fā)GraphicsCon

2011-07-04 17:45:45

Qt Sqlite 數(shù)據(jù)庫

2011-08-17 15:10:21

iPhone開發(fā)Web視圖

2013-01-06 12:23:59

Android開發(fā)SQLite數(shù)據(jù)庫

2011-09-06 16:44:47

IOS應(yīng)用SQLite

2021-05-07 15:36:50

iOS隱藏應(yīng)用程序

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-15 11:13:06

IOS開發(fā)并發(fā)Dispatch Qu

2009-06-02 10:02:50

eclipse jboeclipse jbojboss for e

2021-07-02 20:37:19

Python代碼SRP

2011-08-15 11:37:20

iPhone開發(fā)Mask

2011-08-12 14:33:06

iPhone緩存文件

2022-05-31 08:49:02

Flutter應(yīng)用程序前端
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)