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 7772959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:00:14+00:00 2026-06-01T17:00:14+00:00

i have a core data database that start from the AppDelegate, and there i’ll

  • 0

i have a core data database that start from the AppDelegate, and there i’ll do this:

MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];

masterViewController.managedObjectContext = self.managedObjectContext;

so in this way i can access to the database in the master view, then i want access to the core data in other classes, and i do this:

id delegateContext = [[UIApplication sharedApplication] delegate];

NSManagedObjectContext *context = [delegateContext managedObjectContext];

but when i add, and access the information, i have some bad Exc access and other error in various part of the code when i try to access to the information of the database, so i think that maybe i have used in bad way the core data, to access the information from other classes.

maybe i have to release the delegatecontext?…i haven’t release it in any class i have used it, and if i have release it, where i have do it?

anyone can help me?

  • 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-06-01T17:00:16+00:00Added an answer on June 1, 2026 at 5:00 pm

    Problem is you are taking delegateContext of type id instead of NSManagedObjectContext and assigning it to *contextin these two lines.

    id delegateContext = [[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *context = [delegateContext managedObjectContext]; 
    

    How about adding these lines whenever you need to save or access managedObjectContext, check it if its nil if YES copy it from Appdelegate.

     if (managedObjectContext == nil) 
     { 
        managedObjectContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; 
        NSLog(@"After managedObjectContext: %@",  managedObjectContext);
     }
    

    Just try to remove your these two lines and add the above if condition I am suggesting. Should work.

    Update 1: As you are asking I am mentioning steps for creating
    Appdelegate’s instance to access global properties.

          #import "AppDelegate.h"
    

    after @implementation create instance of Appdelegate

          AppDelegate *app;
    

    in viewDidLoad method…

          app=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableview cell that gets a tally from a core data database.
I have a Core Data in this database should I save images, so how
I have some calculated values in the core data database that I need to
I have a core data model, using the database store, that contains entities with
I have a Core Data based mac application that is working perfectly well until
I have a core data context with objects that have a date stored in
I have several Core Data model version that I have added to my .xcdatamodeld
I have created a core data database in one application which involved sucking out
I have 2 entities in my Core Data database Person and Photo a Person
I have a Core Data database of about 500 objects. These objects are 'cards'

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.