On Aug 29, 2008, at 1:33 PM, Ted Archibald wrote:

I've been racking my brains for a while now and I can't figure out how notifications work.

What I want to do is trigger a method in a session(or application) after an ERXGenericRecord has been updated/inserted. I'm pretty certain that I want to use notifications to do this, but I am lost when it comes to setting one up with the NotificationCenter.

Any ideas?

See bottom of 
http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/Introduction/chapter_2_section_6.html


To send a notification:

NSNotificationCenter .defaultCenter().postNotification("MyObjectChangedNotification", eo);

To receive it:

NSSelector method = new NSSelector("handleChangedObject", new NSArray(new Class[] {NSNotification.class});
NSNotificationCenter.defaultCenter().addObserver(this,
        method, "MyObjectChangedNotification", null);

public void handleChangedObject(NSNotification notification) {
        EOEnterpriseObject eo = (EOEnterpriseObject) notification.object()
        // whatever you want to do here
}

Chuck

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to