I have a Core Data application with a double Core Data implementation, that is, there are two managedObjectModels, persistentStoreCoordinators and managedObjectContexts. These are referenced by the following methods:
// appDelegate.h - (NSPersistentStoreCoordinator *) persistentStoreCoordinatorForConfiguration: (NSString *) configuration; - (NSManagedObjectModel *) managedObjectModelForConfiguration: (NSString *) configuration; - (NSManagedObjectContext *) managedObjectContextForConfiguration: (NSString *) configuration; - (NSManagedObjectContext *) managedObjectContextIpAddresses; // used for bindings - (NSManagedObjectContext *) managedObjectContextRecipes; // used for bindings To make the code cleaner and generic for N objectContexts, I'd like to have them all in an NSDictionary, and bind to the dictionary instead. So, I'd have - (NSMutableDictionary *) managedObjectContextDictionary; which I fill in the appDelegate's init (to do it as early as possible) as follows: - (id) init { self = [super init]; if (self != nil) { managedObjectContextDictionary = [[NSMutableDictionary alloc] init]; persistentStoreCoordinatorDictionary = [[NSMutableDictionary alloc] init]; managedObjectModelDictionary = [[NSMutableDictionary alloc] init]; NSArray * keys = [NSArray arrayWithObjects: recipesConfigurationKey, ipAddressesConfigurationKey, nil]; for(unsigned int i = 0; i < [keys count]; i++) { // we do this because of the bindings NSString * key = [keys objectAtIndex: i]; [managedObjectContextDictionary setObject: [self managedObjectContextForConfiguration: key] forKey: key]; } } return self; } Problem: when I use this, and bind to managedObjectContextDictionary.recipes and managedObjectContextDictionary.ipAddresses, the application *sometimes* hangs after startup. That is, the interface does not work, and there is no spinning ball either; it is just dead. When using the debugger, it does work OK. I checked that the whole Core Data implementation is set up, as well as the dictionary. Questions: 1. What could be the difference with binding to - (NSManagedObjectContext *) managedObjectContextRecipes { return [self managedObjectContextForConfiguration: recipesConfigurationKey]; } ? 2. Is it correct to set up the dictionary in - init? 3. Could there be a timing problem? Thanks in advance, Arthur C. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]