• 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
Re: Delegate & Notification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delegate & Notification


  • Subject: Re: Delegate & Notification
  • From: Bing Li <email@hidden>
  • Date: Mon, 16 May 2011 21:31:18 +0800

Dear Michael,

You are right. There is no RunLoop in the code. Actually, although I have
got to know the term, RunLoop, when starting to learn Cocoa for two months,
until now I have not seen a sample code about RunLoop in any resources. So I
don't know how to program with it.

I have one question. If I put the synchronous notification posts into a
NSOperationQueue, it must also get asynchronous notification, right? Is the
solution proper?

Best regards,
Bing

On Mon, May 16, 2011 at 7:01 PM, Michael Babin <email@hidden> wrote:

> On May 16, 2011, at 3:49 AM, Bing Li wrote:
>
>     - (void) Print
>     {
>         NSLog(@"I am doing a tough job!");
> //      [[[NSNotificationQueue alloc]
> initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
> enqueueNotification: [NSNotification notificationWithName:@"Done"
> object:self] postingStyle:NSPostNow]; // This is also sychronous.
>         [[[NSNotificationQueue alloc]
> initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
> enqueueNotification: [NSNotification notificationWithName:@"Done"
> object:self] postingStyle:NSPostWhenIdle];
>         NSLog(@"I need to leave!");
>     }
>
> The commented line is the same as a synchronous notification. It works. But
> the later line must be an asynchronous notification. However, the
> AppController does not get notified. I don't understand what's wrong with
> the code.
>
>
> There is another current thread on this list ("NSPostWhenIdle not doing its
> job") which is also discussing NSNotificationQueue and how it works. You
> might refer to it for more information, including a link to one of Mike
> Ash's Friday Q&A blog entries on NSNotificationQueue:
> http://www.mikeash.com/pyblog/friday-qa-2010-01-08-nsnotificationqueue.html
> .
>
> Since NSPostWhenIdle posts the event when the run loop is idle, the first
> question would be: do you have a runloop? Your original post included the
> following:
>
> In the main code, the above objects are utilized as follows.
>
>    WorkingApp *app = [[WorkingApp alloc] init];
>    AppController *controller = [[AppController alloc] init];
>
>    [app Print];
>
>    char s[100];
>    scanf("%s", s);
>    [app release];
>    [controller release];
>
>
> Which seems to indicate that you don't have a runloop in your sample code.
>
>
>
_______________________________________________

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: Delegate & Notification
      • From: Michael Babin <email@hidden>
References: 
 >Delegate & Notification (From: Bing Li <email@hidden>)
 >Re: Delegate & Notification (From: Michael Babin <email@hidden>)
 >Re: Delegate & Notification (From: Bing Li <email@hidden>)
 >Re: Delegate & Notification (From: Michael Babin <email@hidden>)

  • Prev by Date: Core Animation animations stop prematurely at random
  • Next by Date: Re: No more .ibplugins in Xcode 4, so now what...?
  • Previous by thread: Re: Delegate & Notification
  • Next by thread: Re: Delegate & Notification
  • Index(es):
    • Date
    • Thread