Search code examples
objective-ccocoaobjective-c++nsalert

Cocoa How to display Informative Message


I need to display informative message box in Cocoa Application, which control should i use, i read the document of NSAlert, but it seems, it will create the modal message box, where i need something, where i will just show a popup for fraction of seconds and will get destroyed after some time by it self.


Solution

  • you could use the NSTimer for auto dismiss.

    [self showMyMessage];//put your code in showMyMessage method to show your alert,
    NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval:60.0 target:self
    selector:@selector(callToDismissAlert:) userInfo:nil repeats:NO];
    

    After 60.0 second , iOS will call the below function

    -(void) callToDismissAlert:(NSTimer*) t 
    {
        [self dismissMyAlert];// put your code in dismissMyAlert method to dismiss your alert,
    }