Re: canCloseDocumentWithDelegate
Re: canCloseDocumentWithDelegate
- Subject: Re: canCloseDocumentWithDelegate
- From: Ryan Bates <email@hidden>
- Date: Thu, 26 Feb 2004 09:33:06 -0800
Well, you would normally pass the message on to super. This would check
if the document needs saving, etc. and call the "shouldCloseSelector"
with YES or NO appropriately. Example:
[super canCloseDocumentWithDelegate:delegate
shouldCloseSelector:selector contextInfo:contextInfo];
As a result, the document isn't guaranteed to close, therefore,
"canCloseDocument..." probably isn't the best method to do the clean
up. The "close" method might be a better choice, but remember to pass
it on to super.
Just so you know, if you do a special check in the
"canCloseDocument..." method and you want to send "NO" then you will
need to call the selector yourself. For calling selectors, you could
use one of NSObject's "performSelector:..." methods; however, in this
case the selector requires three arguments and not all of the arguments
are objects. Instead, you can use the objc_msgSend() function. It is
defined like this:
id objc_msgSend(id theReceiver, SEL theSelector, ...)
I believe your document should call it like this:
if ([delegate respondsToSelector:selector]) {
objc_msgSend(delegate, selector, self, NO, contextInfo);
}
I've never done this before, but this is how I understand it from
reading the docs. Someone please correct me if I'm wrong.
Ryan
On Feb 26, 2004, at 6:35 AM, Peter Hudson wrote:
I notice that the method canCloseDocument is deprecated.
I therefore want to use
canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo.
I have overridden this method in my document class and perform some
clean up in it. I want to then proceed to close the document. To do
this the documentation tells me to "call the callback with YES"
I assume the callback is the shouldCloseSelector. How do I call it
with YES. I can't find an example of calling a selector.
Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.