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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:34:47+00:00 2026-05-13T22:34:47+00:00

I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I

  • 0

I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I didn’t change the default code that XCode generates.

I declare a instance variable of that type in my app delegate and in my appDidFinishLaunching method, I have been try to assign it’s value from a object retrieved from the database like this:

    NSFetchRequest      *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity  = [NSEntityDescription entityForName:@"ConfiguracaoDaApp" inManagedObjectContext:self.managedObjectContext];

    [request setEntity:entity];
    configDaApp = [[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];

The problem is that the line

[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];

don’t returns a object of the type ConfiguracaoDaApp.

I tried change the line to this:

configDaApp = [[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0] entity];

Then a NSEntityDescriptor is returned and the problem remains the same.

So, my question is: how to retrieve a real business object from a executeFetchRequest?

Thanks in advance.

Obs: forgive me if it is a beginner question but is my first iPhone app.

  • 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-13T22:34:48+00:00Added an answer on May 13, 2026 at 10:34 pm

    I just figure out what is happening:

    [[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];
    

    returns a autorelease object and when I tried to access the property in other parts of the code, its contents was memory trash of the application because the original ConfiguracaoDaApp object was released by autorelease pool. My property was declared with retain, but the object is autoreleased anyway. So I putted explicitly a retain in the line:

    configDaApp = [[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0] retain];
    

    Then everything works fine.

    Thanks anyway, guys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a table that dynamically generates text boxes in run time. I want to
Have following Java code,that creates StringBuilder with \n,i.e. carriage return delimiters: while (scanner.hasNextLine()){ sb.append(scanner.nextLine()).append(\n);
Have a fun issue with sharepoint calendar view filtering. That code works fine: SPSecurity.RunWithElevatedPrivileges(delegate()
have next code: class GameTexture { private: LPDIRECT3DTEXTURE9 texture; unsigned char *alphaLayer; UINT width,
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
Have a build process that can't be edited and need to pack another war
Have a photography site that I want to prevent image copying from. How can
Have created a ATL COM project through which I am inserting Menu Items to

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.