Hiding NSPanel through a timer in Cocoa
I am new开发者_运维问答 to Cocoa and would like to know how to hide an NSPanel when a timer tick, I have tried to call [myNSPanel orderout:self], the code runs but the panel is still there. Do I need to do something different? Thanks in advance.
For one thing, the selector is orderOut:
, and selectors are case-sensitive, so if your code actually says orderout:
, then you're getting a does-not-respond-to-selector exception (which you can see in the Debugger Console) and that's why your code isn't working.
If it still doesn't work after you fix that, make sure myNSPanel
(which I assume is an outlet) is actually hooked up to the panel in question. A very common mistake is to forget to connect the outlet; when you do this, the pointer in the outlet variable is nil
, and a message to nil
simply does nothing.
You can check this by logging the pointer: NSLog(@"%p", myNSPanel);
. After that statement runs, the Debugger Console will contain a line telling you what pointer was in the myNSPanel
variable. If it's 0x0
, that's nil
.
精彩评论