Re: Core data question in multiwindow doc app

2008-06-28 Thread Steven Hamilton



On 28/06/2008, at 2:41 PM, Chris Hanson wrote:


On Jun 27, 2008, at 7:25 PM, Steven Hamilton wrote:

	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(buildSourceList)  
name:@NSManagedObjectContextObjectsDidChangeNotification object: 
[self.document managedObjectContext]];


Notification names should always use the global variables declared  
for them, not a constant string.


There is never any guarantee that the value of a notification name  
is identical to its name.


Whether this is your issue, I don't know.  How did you create your  
document's window controllers and ensure that it knows about them?


Thanks. That seems to have fixed it. This also gives me a big clue to  
a similar bug I've to chase next.

___

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]


Core data question in multiwindow doc app

2008-06-27 Thread Steven Hamilton

Easy one this I reckon (but not that easy or I wouldn't ask),

I've converted my core data app to NSPersistentDocument and using a  
multi-nib model for my 3 windows. I have an account window using the  
IB wizard Master-Detail interface with bindings to add and manage  
Account entities. I also have a transaction window which has an  
outlineview of my Accounts. This uses the standard datasource and  
delegate methods and I build a manual tree of accounts during  
awakeFromNib for that window.


When I add a new account entity my outlineview doesn't know. Should I  
be using a notification to find out when a new account entity is  
added. If so, which one?

___

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]


Re: Core data question in multiwindow doc app

2008-06-27 Thread Steven Hamilton


On 28/06/2008, at 4:32 AM, Ben Trumbull wrote:


When I add a new account entity my outlineview doesn't know. Should I
be using a notification to find out when a new account entity is
added. If so, which one?


The easiest way to track insertions and deletions in the  
NSManagedObjectContext is the notification  
NSManagedObjectContextObjectsDidChangeNotification.


Yep, seems easy enough but I can't get it to send a notification. I  
add an Account entity and the notification isn't sent. However, if I  
save and reload the file, or close and reopen the window with the  
outlineview my tree is rebuilt and I see the new account. I'm sure its  
to do with the way I'm referencing the manageObjectContext. I'm not  
very happy about this [self.document ] path I keep using. Is this the  
correct way to source the MOC in a  document app?


	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(buildSourceList)  
name:@NSManagedObjectContextObjectsDidChangeNotification object: 
[self.document managedObjectContext]];


___

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]