• 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
Asynchronous Notification Does NOT Work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Asynchronous Notification Does NOT Work


  • Subject: Asynchronous Notification Does NOT Work
  • From: Bing Li <email@hidden>
  • Date: Mon, 06 Jun 2011 00:20:16 +0800

Dear all,

I just learned the technique of asynchronous notification. This is the first
time for me to use it in my system. However, I got a weird problem. Only
synchronous notification works well. If replacing the synchronous
notification lines of code with asynchronous ones, it does not work.

My system is a Cocoa Application. I know RunLoop is created automatically in
such a project. So asynchronous notification should work. The primary code
is as follows.

        ......

        // The following two lines are the parameters to be transmitted with
the notification.
        NSMutableDictionary *connectionDisconnectedDictionary =
[[[NSMutableDictionary alloc] initWithCapacity:5] autorelease];
        [connectionDisconnectedDictionary setObject:serviceKey forKey:@
"SERVICE_KEY"];

        // This line does not work.
//      [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED"
object:self userInfo:connectionDisconnectedDictionary]
postingStyle:NSPostWhenIdle];

        // This line works well.
//      [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostNow];

         // It does not work.
//       [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostASAP];

        // It works
        [[NSNotificationCenter defaultCenter]
postNotificationName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary];

        ......

The registration and events code is the same. So I felt confused.

Could you please give me a hand? What reasons might cause the above problem?

Best,
Bing
_______________________________________________

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: Asynchronous Notification Does NOT Work
      • From: Ken Thomases <email@hidden>
    • Re: Asynchronous Notification Does NOT Work
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Good and updated book for iPhone development
  • Next by Date: Re: Asynchronous Notification Does NOT Work
  • Previous by thread: Re: [ANN] CoreParse
  • Next by thread: Re: Asynchronous Notification Does NOT Work
  • Index(es):
    • Date
    • Thread