2016-12-02 55 views
0

繼續獲取零對象模型,並經歷了幾個其他職位和所有我能找到的步驟。核心數據無對象模型錯誤

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@「DBname」 withExtension:@"momd"]; 
  • 數據庫名稱的DBname.xcdatamodel文件名
  • DBname.xcdatamodel是在複製捆綁資源和源文件列表
  • 做了一個乾淨的構建並重新啓動
  • 該文件將在取景器中存在匹配
  • 沒有衝突的重複文件
  • 已完成新鮮應用安裝

是否有另一個步驟來找到模型路徑。

+0

只是猜測,但該文檔說的文件名應該是DBname.momd(https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/InitializingtheCoreDataStack.html) –

回答

0

與擴展媽媽工作,而不是媽媽。爲核心數據堆棧添加了一個條件。

//try first extension 

modelURL = [[NSBundle mainBundle] URLForResource:@"modelFile" withExtension:@"momd"]; 

if (!modelURL) 
{ 
    //try another extention 
    modelURL = [[NSBundle mainBundle] URLForResource:@"modelFile" withExtension:@"mom"]; 
}