简体   繁体   English

如何将解析的xml传递到核心数据对象

[英]how to pass parsed xml into core-data object

I am currently setting up core-data into my application that I have already started, I have all of the core data delegates set up and have completed everything in this tutorial. 目前,我正在将已经启动的核心数据设置到我的应用程序中,我已经设置了所有核心数据委托,并且已经完成了教程中的所有内容。

I already have my NSXMLParser delegates working separately to my core data (currently I am caching the results etc etc.) but now I would like to pass all of the parsed data into the coredata object, but I have no idea where to start. 我已经有我的NSXMLParser委托分别处理我的核心数据(当前正在缓存结果等),但是现在我想将所有已解析的数据传递给coredata对象,但是我不知道从哪里开始。

This is what my parserDidEndDocument looks like, I think I pass the parsed data through to my code data in here? 这就是我的parserDidEndDocument样子,我想我将解析后的数据传递到这里的代码数据中?

- (void)parserDidEndDocument:(NSXMLParser *)parser
{
    if (dataSetToParse == @"ICMfg") 
    {
       //Filter results (ISVEHICLE = T)
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"ISVEHICLE",@"T"];
        NSArray *filteredArray = [myDataArray filteredArrayUsingPredicate:predicate];
        //Passes Manufacturer strigs over to startSortingtheArray method
        [self startSortingTheArray:[filteredArray valueForKey:@"MANUFACTURER"]];

        //Loading Messages etc
        [self scrollToRowAtIndexPath];
        [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(stopAnimating) userInfo:nil repeats:NO];
    }
    //...etc

The data set I want to parse is ICMFg (thats the xml I am parsing).. so do I, and if I do would I pass the data over to the core-data from here? 我要解析的数据集是ICMFg(也就是我正在解析的xml)..我也可以,如果可以的话,我可以将数据从此处传递给核心数据吗? or am I wrong. 还是我错了。 also once the data is in the core data.. if the user tries to reload the list again later on how do I call from core data instead of parsing? 同样,一旦数据位于核心数据中。.如果用户稍后尝试重新加载列表,那么我如何从核心数据调用而不是解析?

I have been looking around the net for examples but thought someone might be able to help here.. I will keep looking but I just not to sure about how it works with me because I am adding core data to my app after I have already started... 我一直在网上寻找示例,但认为有人可能会在这里提供帮助。.我会一直在寻找,但我只是不确定它如何工作,因为我已经在启动后将核心数据添加到我的应用程序中...

Create your coreData model (that is, what the class you will save look like). 创建您的coreData模型(即您将保存的类的外观)。 Then generate the class files. 然后生成类文件。 To do that, follow this simple tutorial . 为此,请遵循此简单教程

When you are done, just create a new instance of the class, with your data inside, and call save on it, (it is in the tuto too). 完成后,只需创建类的新实例,并在其中包含数据,然后在其上调用save(它也位于tuto中)。

Good luck! 祝好运!

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

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