久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='EJ4Qu'></bdo><ul id='EJ4Qu'></ul>

  • <i id='EJ4Qu'><tr id='EJ4Qu'><dt id='EJ4Qu'><q id='EJ4Qu'><span id='EJ4Qu'><b id='EJ4Qu'><form id='EJ4Qu'><ins id='EJ4Qu'></ins><ul id='EJ4Qu'></ul><sub id='EJ4Qu'></sub></form><legend id='EJ4Qu'></legend><bdo id='EJ4Qu'><pre id='EJ4Qu'><center id='EJ4Qu'></center></pre></bdo></b><th id='EJ4Qu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EJ4Qu'><tfoot id='EJ4Qu'></tfoot><dl id='EJ4Qu'><fieldset id='EJ4Qu'></fieldset></dl></div>

    <small id='EJ4Qu'></small><noframes id='EJ4Qu'>

    1. <legend id='EJ4Qu'><style id='EJ4Qu'><dir id='EJ4Qu'><q id='EJ4Qu'></q></dir></style></legend>
    2. <tfoot id='EJ4Qu'></tfoot>

        如何以一對多關系清除/重置所有CoreData

        How to clear/reset all CoreData in one-to-many relationship(如何以一對多關系清除/重置所有CoreData)
          <tbody id='tm2Ae'></tbody>
        <tfoot id='tm2Ae'></tfoot>

              <small id='tm2Ae'></small><noframes id='tm2Ae'>

                  <bdo id='tm2Ae'></bdo><ul id='tm2Ae'></ul>
                • <legend id='tm2Ae'><style id='tm2Ae'><dir id='tm2Ae'><q id='tm2Ae'></q></dir></style></legend>
                  <i id='tm2Ae'><tr id='tm2Ae'><dt id='tm2Ae'><q id='tm2Ae'><span id='tm2Ae'><b id='tm2Ae'><form id='tm2Ae'><ins id='tm2Ae'></ins><ul id='tm2Ae'></ul><sub id='tm2Ae'></sub></form><legend id='tm2Ae'></legend><bdo id='tm2Ae'><pre id='tm2Ae'><center id='tm2Ae'></center></pre></bdo></b><th id='tm2Ae'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tm2Ae'><tfoot id='tm2Ae'></tfoot><dl id='tm2Ae'><fieldset id='tm2Ae'></fieldset></dl></div>
                  本文介紹了如何以一對多關系清除/重置所有CoreData的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用 coreData,具有一對多的關系,我有一個文件夾實體和一個文件實體.一個文件夾可以有很多文件等等.

                  I am using coreData, with one -to-many realtionship, I have a folder entity and a file entity. A folder can have many files and so on.

                  所以,我有兩個 ViewController,FolderViewController 和 FileViewController,它們分別包含文件夾和文件.現在我有一個 modalView,它可以從文件夾和文件 viewcontroller 訪問.在這個 VC 中,我有一個按鈕來重置所有數據.因此,當我單擊此按鈕時,我希望所有數據都應重置.

                  So, I have two ViewControllers, FolderViewController and FileViewController which contains folders and files respectively.Now I have a modalView , which is accesible from both folder and file viewcontroller. In this VC I have a button to Reset all Data. So when I click this I want all the data should reset.

                  我使用了這段代碼,這個函數寫在 appdelegate.m 中并從我的 VC 中調用.

                  I used this code,this function is written in appdelegate.m and called from my VC.

                  - (void)resetToDefault
                  {
                      NSError * error;
                      // retrieve the store URL
                      NSURL * storeURL = [[__managedObjectContext persistentStoreCoordinator] URLForPersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject]];
                      // lock the current context
                      [__managedObjectContext lock];
                      [__managedObjectContext reset];//to drop pending changes
                      //delete the store from the current managedObjectContext
                      if ([[__managedObjectContext persistentStoreCoordinator] removePersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject] error:&error])
                      {
                          // remove the file containing the data
                          [[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
                          //recreate the store like in the  appDelegate method
                          [[__managedObjectContext persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error];//recreates the persistent store
                      }
                      [__managedObjectContext unlock];
                      //that's it !
                  
                      NSLog(@"buttonReset Pressed");
                  }
                  

                  所以在我關閉視圖時單擊 resetButton 后,我收到此錯誤

                  So after clicking on resetButton when I close the View, I get this error

                  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Object's persistent store is not reachable from this NSManagedObjectContext's coordinator'
                  

                  那么如何解決這個問題.

                  So how to solve this.

                  問候蘭吉特

                  推薦答案

                  這個問題我已經解決了,下面是代碼,

                  I have solved this problem, below is the code,

                  這個函數已經寫在appdelegate.m中

                  This function has been written in appdelegate.m

                  - (void) resetApplicationModel
                  {
                      NSError *error;
                      NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"AppName.sqlite"];
                      [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];
                      for (NSManagedObject *ct in [self.managedObjectContext registeredObjects]) {
                          [self.managedObjectContext deleteObject:ct];
                      }
                  
                      //Make new persistent store for future saves   
                      if (![self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
                          // do something with the error
                      }  
                  }
                  

                  在我的 SettingsViewController 中,我在以這種方式單擊的重置按鈕上調用它.

                  And in my SettingsViewController, I am calling this on resetbutton clicked in this way.

                  - (void)resetButtonclicked
                  {
                  AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                          [appDelegate resetApplicationModel];  
                  }  
                  

                  問候蘭吉特.

                  這篇關于如何以一對多關系清除/重置所有CoreData的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))

                  <small id='VJyjZ'></small><noframes id='VJyjZ'>

                      <tbody id='VJyjZ'></tbody>
                      1. <tfoot id='VJyjZ'></tfoot>
                        <legend id='VJyjZ'><style id='VJyjZ'><dir id='VJyjZ'><q id='VJyjZ'></q></dir></style></legend>
                        <i id='VJyjZ'><tr id='VJyjZ'><dt id='VJyjZ'><q id='VJyjZ'><span id='VJyjZ'><b id='VJyjZ'><form id='VJyjZ'><ins id='VJyjZ'></ins><ul id='VJyjZ'></ul><sub id='VJyjZ'></sub></form><legend id='VJyjZ'></legend><bdo id='VJyjZ'><pre id='VJyjZ'><center id='VJyjZ'></center></pre></bdo></b><th id='VJyjZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VJyjZ'><tfoot id='VJyjZ'></tfoot><dl id='VJyjZ'><fieldset id='VJyjZ'></fieldset></dl></div>
                          <bdo id='VJyjZ'></bdo><ul id='VJyjZ'></ul>

                            主站蜘蛛池模板: 伊人91在线 | 91精品免费 | 亚洲品质自拍视频 | 福利片在线观看 | 国产一二三区免费视频 | 男女在线免费观看 | 精品国产一区二区在线 | 天天操天天射综合网 | 久久黄色网 | 伊人婷婷 | 免费高清成人 | 国产一区二区久久 | 一级在线视频 | 日韩有码一区 | 欧美精品一区三区 | 亚洲一二视频 | 高清视频一区二区三区 | 日韩午夜电影 | 亚洲综合婷婷 | 日韩精品视频一区二区三区 | 可以看黄的视频 | 成人午夜视频在线观看 | 国产精品久久久久久久久久久久冷 | 国产精品高潮呻吟久久 | 久久国内 | 91精品国产一区二区三区 | 国产剧情一区 | 夜夜骚 | 69福利影院 | 精品久久99 | 亚洲精品1区2区3区 91免费看片 | 亚洲免费观看视频网站 | 国产精品日日摸夜夜添夜夜av | 久久国产电影 | 精品久久久久香蕉网 | 国产精品视频一区二区三区四区国 | 色视频网站 | 久久精品亚洲国产 | 欧美精品久久久久久久久久 | 91视频在线观看免费 | 成人在线免费观看视频 |