开发者

Using windowWillClose on multiple windows?

开发者 https://www.devze.com 2023-02-20 21:46 出处:网络
I\'m pretty new to cocoa so please excuse me for any stupid mistakes I make. So I开发者_开发问答 have two windows, one I\'ve used windowWillClose on it:

I'm pretty new to cocoa so please excuse me for any stupid mistakes I make. So I开发者_开发问答 have two windows, one I've used windowWillClose on it:

-(void) awakeFromNib{
[window1 setDelegate:self];
[window2 setDelegate:self];
}
-(void)windowWillClose:(NSNotification *)aNotification {
[[window1 animator] setAlphaValue:0.0];
isOpen = NO;
NSLog (@"Window closed");
}

However on the second window when I set delegate on it and try to use windowWillClose, I realise I can't as it's a duplicate method of the first windowWillClose. I've heard of windowShouldClose, but I'm not too sure about it. Please help me, I'm pretty stumped on this one, and Apple's references didn't have any explanation for this. Thanks


Instead of calling [window1 animator] you can use the object value of the passed-in aNotification to fade out whichever window triggered the delegate method.

0

精彩评论

暂无评论...
验证码 换一张
取 消