简体   繁体   English

尝试将数据预加载到核心数据存储中

[英]Attempting to Pre-load Data into Core Data Store

Sup fellas, I am using the script that a fellow stack overflow user posted here (the post by kalperin) to pre-load data to an SQL Lite store. 伙计们,我正在使用一个堆栈溢出用户在此处发布的脚本(kalperin的发布)将数据预加载到SQL Lite存储中。 So I have a command-line utility project that I am using and I have an iPhone application in which I successfully parsed my .plist file and stored it in Core Data, and I am trying to copy over code from my iPhone application to this command-line utility(the plist parsing parts at least). 因此,我有一个正在使用的命令行实用程序项目,并且有一个iPhone应用程序,在其中成功解析了.plist文件并将其存储在Core Data中,并且我试图将代码从我的iPhone应用程序复制到此命令中。行实用程序(至少plist解析部分)。 The data model I have made looks like so: 我制作的数据模型如下所示:

替代文字

Those two classes inherit from ParkingRegionOverlay which requires the MapKit framework which is not addable to a project of this type(as far as I know). 这两个类从ParkingRegionOverlay继承,ParkingRegionOverlay需要MapKit框架,而该框架不能添加到此类项目中(据我所知)。 So my questions: 所以我的问题是:

  1. How would I bypass this problem(ie How do I get the Mapkit framework as part of my command-line utility project?)? 我将如何绕过此问题(即如何将Mapkit框架作为命令行实用程序项目的一部分?)?
  2. Do I need to include my .xcdatamodel file in the command-line utility project and reference it in any way? 我是否需要在命令行实用程序项目中包括我的.xcdatamodel文件并以任何方式引用它? If someone wouldn't mind shedding some light in this area it would be greatly appreciated, as I think I do need my project to know about the data model, but am not quite sure. 如果有人不介意在该领域有所作为,那将不胜感激,因为我认为我确实需要我的项目来了解数据模型,但并不确定。

Thanks in advance for any help! 在此先感谢您的帮助!

you absolutely need the xdatamodel file in your project. 您绝对在项目中需要xdatamodel文件。 It will be "compiled" into a momd file and included in your application bundle. 它将被“编译”为一个momd文件,并包含在您的应用程序包中。 Core Data needs this to know what your data model looks like (that's the whole point of the data model file). Core Data需要此信息来知道您的数据模型是什么样子(这就是数据模型文件的重点)。

This might help you, too: Can't find momd file: Core Data problems 这也可能对您有帮助: 找不到妈妈文件:核心数据问题

Also, why do you mix Model and View by having your data model classes inherit from an Overlay class. 另外,为什么要通过让数据模型类继承自Overlay类来混合使用Model和View。 It seems that you can solve your problem simply by adhering to MVC practices. 看来您只要遵循MVC惯例就可以解决您的问题。

Cheers, 干杯,

Johannes 约翰尼斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM