English 中文(简体)
启动式核心数据——模型
原标题:beginner iOS core data - model is nil

采用X代码4.2,我用表格格式模板制作了新的标识。 出于某种原因,这一模板没有给你列入核心数据的选择,因此,我不得不人工添加这一模板。

http://www.theappcodeblog.com/06/30/iphone-development-add-core-data-to-a-tab-bar-application-and-save-user-data/

然而,当我掌握情况时,我发现这一错误:

Cannot create an NSPersistentStoreCoordinator with a nil model

我如何使这一模式变得不成熟? 我建立了模型.xcdatamodeld,并增加了一个具有属性的实体(Cat)。

Also, I want to have the app begin with 5 cats for example, but the user will be able to create more cats. Where/How do I create the original 5 cats? It doesn t seem logical to create them every time the app starts, but how can you create them in the first place?

最佳回答
  1. 在你试图建立一个持续的仓库协调员之前,你需要立即采用一种模式。 你们可以这样做,其中一种方法是:+合并的ModelFromBundles:。 请注意,如果你采用这种方法,就会寻找模型的主要障碍,这或许是你想要的。

  2. 为了向仓库提供一些初步数据,你有一些选择。 当你开始并重新设立核心数据组时,你或许会寻找一个现有的固定储存库。 如果你发现的话,你就能够创建老板,给协调员增加,并着手进行。 如果找不到,一种选择是建立一个新的仓库,并在方案上增加一些物体。 另一种选择是,在贵轴心中保存一个预先储存的永久存放文件,然后打开。 三分之一可能读到网络服务器的缺省数据,并用于新储存。

问题回答

固定如下:

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Model" withExtension:@"momd"];

“示范”是“TEMP”。

我仍然不知道如何制造5个物体。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签