• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Loading Entities from a CoreData document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading Entities from a CoreData document


  • Subject: Re: Loading Entities from a CoreData document
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 16 Apr 2009 22:55:24 -0700


On 2009 Apr 16, at 22:04, David Zwerdling wrote:

The issue is, when using code like this (url points to a document full of data sets):

NSPersistentDocument *pd = [NSPersistentDocument new];
BOOL success = [pd configurePersistentStoreCoordinatorForURL:url ofType:NSXMLStoreType modelConfiguration:nil storeOptions:nil error:&error];
NSSet *ros = [[pd managedObjectContext] registeredObjects];


success comes back true, but there are no managed objects in 'ros'.

I've never used -registeredObjects. You might want to try my little - allObjects method given below and see if you get the same empty results.


So, is there some sample code I can see which loads the managed objects of an xml file? I've looked pretty exhaustively and everything seems too high level (relying on the single-file model that I implemented in my original application.)

Well, I don't think your situation is any different than what's in the sample code available. For example, DepartmentAndEmployees has a method which fetches the 'Department'.


Actually, and I want to go to bed now, but just quickly looking at your code above it looks like there might be some things missing. Creating a persistence stack usually takes me a few more lines than that. Don't you need to plug in a managed object model somewhere?


- (NSArray*)allObjects { NSError* error_ = nil ;

NSFetchRequest* fetchRequest ;
fetchRequest = [[NSFetchRequest alloc] init];
NSManagedObjectContext* moc = <<whatever>> ;
[fetchRequest setEntity:[NSEntityDescription entityForName:<<whatever>>
inManagedObjectContext:moc]];
NSArray* allObjects = [moc executeFetchRequest:fetchRequest
error:&error_] ;
if (error_) {
[[self errorHandler] setError:error_] ;
NSLog(@"Error executing fetch request: %@", [error_ localizedDescription]) ;
}
[fetchRequest release] ;


    return allObjects ;
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Loading Entities from a CoreData document
      • From: David Zwerdling <email@hidden>
References: 
 >Loading Entities from a CoreData document (From: David Zwerdling <email@hidden>)

  • Prev by Date: Loading Entities from a CoreData document
  • Next by Date: Re: Reading in dictionary from txt file: options for speed
  • Previous by thread: Loading Entities from a CoreData document
  • Next by thread: Re: Loading Entities from a CoreData document
  • Index(es):
    • Date
    • Thread