• 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
NSNotificationCenter mystery
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNotificationCenter mystery


  • Subject: NSNotificationCenter mystery
  • From: John Larson <email@hidden>
  • Date: Fri, 4 Sep 2009 10:13:25 -0500

Hi All,

I am putting some unit tests together and am running upon an oddity that I don't understand (and trying to tell myself that WebObjects isn't being end-of-lifed because everything is "legacy" documentation - I'm freaking out!).  Anyways, if I do this:

public class PurchasingTest extends XTest {


public class ECLogger{
public void logECMsg(NSNotification n){
Logger.getLogger(this.getClass()).debug("EC sent " + n.name());
}
}


@Test
public void simpleECChangeTest(){
EOEditingContext ec = ERXEC.newEditingContext();
ec.lock();
NSNotificationCenter.defaultCenter().addObserver(new ECLogger(), 
new NSSelector("logECMsg", new Class[]{NSNotification.class}), 
null, 
ec);
User user = Utils.newEntityForClass(ec, User.class);
ec.saveChanges();
// NSNotificationCenter.defaultCenter().addObserver(new ECLogger(), 
// new NSSelector("logECMsg", new Class[]{NSNotification.class}), 
// null, 
// ec);
user.setNickname("friend");
ec.saveChanges();
ec.unlock();
}
}

I get nothing in the log.  If I switch the comments to add the observer at the latter spot, then I get this in the console, which looks okay to me:

7170 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOEditingContextWillSaveChanges
7171 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOObjectsChangedInStoreNotification
7171 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOObjectsChangedInEditingContextNotification
7171 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent ObjectsWillChangeInEditingContext
7181 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOEditingContextDidSaveChangesNotification
7183 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOObjectsChangedInStoreNotification
7183 [main] DEBUG tests.PurchasingTest$ECLogger  - EC sent EOObjectsChangedInEditingContextNotification

I don't get it.  Any ideas?  I thought maybe it had something to do with the save, but the fact is that I am running the exact same routine with the same EO data and everything.  The only thing that is different is where I add the observer.  I am on 5.3 still and using Wonder for 5.3.

Thanks in advance,
John
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSNotificationCenter mystery
      • From: John Larson <email@hidden>
  • Prev by Date: Re: FOSS Reporting Libraries?
  • Next by Date: Re: Combining EXTJS with WebObjects.
  • Previous by thread: Re: FOSS Reporting Libraries?
  • Next by thread: Re: NSNotificationCenter mystery
  • Index(es):
    • Date
    • Thread