Domanda

I have a huge xml data that i need to put it into the core data sqlite. To parse this xml do i need to create modal classes separately or can somehow directly put it into core data instead of an intermediate class?? If i cannot not put the data into core data directly , can use the NSManagedObject class instead of a modal classes for the parser?

È stato utile?

Soluzione

You need to create your model for Core Data. It cannot and will not just "read" the xml structure and create your model.

You do not need to create NSManagedObject subclasses though.

Update

When you parse XML in Objective-C you do not need to create model objects at all. You can use instances of NSArray and NSDictionary to "model" anything that can come out of an XML file. Therefore you only need to create a Core Data model. In fact you can parse XML directly into Core Data without having an intermediary structure. The flow would be:

  1. Start stream read
  2. When an object is discovered create Core Data object
  3. Store data in CD object as it is read in
  4. If sub object is discovered go into recursion (step 2)
  5. When object is complete clear object and prepare for next object.

XML is a heavy format but it is no more complicated to parse than JSON.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top