Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 617023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:23:23+00:00 2026-05-13T18:23:23+00:00

I’m writing an iPhone app which fetches an XML file, parses it and then

  • 0

I’m writing an iPhone app which fetches an XML file, parses it and then saves the parsed objects to Core Data. I’ve got everything working up to the point where I save the objects to Core Data. I imagine it’s got something to do with how I’m referencing the ManagedObjectContext but I can’t figure out where I’m going wrong. I’ve looked at the SO question here but I’m still stumped. I’ve followed the Core Data Tutorial for iPhone and got that working, but seem to have hit a problem applying what I’ve learned to my own project. My app is different in structure to the example in the tutorial.

My app is a UITabBar with three subviews, let’s call them A, B and C and a separate class file which is just used for fetching the XML called XMLParser. This XML fetching class is called on the press of a button in ViewController ‘C’.

When I parse the XML, I try to save the parsed objects on-the-fly to Core Data. It fails on the first attempt with the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'+entityForName: could not locate an NSManagedObjectModel for entity name 'Branch'' 

In my app delegate, I have the following code relating to my xmlparser class:

At the top of the AppDelegate.m file

#import "XMLParser.h"

Inside applicationDidFinishLaunching

NSManagedObjectContext *context = [self managedObjectContext];
XMLParser *xmlparser = [[XMLParser alloc] init];
xmlparser.managedObjectContext = context;
[xmlparser release];

Instead of pasting massive chunks of code into the question right now, if someone can see anything up with what I’ve written so far then please ask for more code or a better explanation.

Edit: I’ve checked everything in the accepted answer for this SO question and I have all this configured

Thanks


EDIT

I realise now that because I actually instantiate an XMLParser object upon the press of a button in ViewController C, the managedObjectContext set in applicationDidFinishLaunching does not apply to the newly instantiated object. So, how do I give the XMLParser access to my applications ManagedObjectContext when I instantiate it after pressing the button on my ViewController?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:23:23+00:00Added an answer on May 13, 2026 at 6:23 pm

    You are creating an XMLParser object and setting its managed object context. This is fine.

    However, then you release it. If you plan to use the object, you should not release it immediately.

    UPDATE
    You can pass the managed object context into your view controller(s) in applicationDidFinishLaunching:. You can also get it from the app delegate or another singleton that manages your Core Data stack.

    You can get the managed object context from the app delegate like this:

    [UIApplication sharedApplication].delegate.managedObjectContext
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app for my school newspaper, which is run completely online
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am writing an app with both english and french support. The app requests
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.