Guys,
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.