Status string can't be displayed in the NSTextField

Discussion in 'Mac Programming' started by MayPeng, Jul 13, 2011.

  1. MayPeng macrumors member

    Joined:
    Nov 21, 2010
    #1
    I have a controller class : AppController

    AppController.h
    IBOutlet NSTextField *m_field_status;

    - (void)setStatus;
    - (void)finishUpgrading;


    AppController.m
    - (id)init
    {
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self selector:mad:selector(finishUpgrading) name:EnumerationFinishedNotification object:nil];
    }

    - (void)setStatus
    {
    [m_field_status setString: @"Starting..."];
    }

    - (void)finishUpgrading
    {
    NSString *str = @"Starting...";
    [str stringByAppendingString:mad:"finished"];
    [m_field_status setString:str];
    }

    I have another class: Upgrade. It will post Notification (finishUpgrading) to AppController class after finishing the upgrading.

    Now the problem is that the NSTextField can't show message immediately after receiving the notification.

    I have loaded the current view after receiving the notification.But it can't make any sense.
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    (Re-)read the NSNotificationCenter class reference. In particular, the requirement stated under notificationSelector of addObserver:selector:name:object:.

    More detailed information is available in the Notification Programming Topics guide.
     

Share This Page