Re: how does canCloseDocumentWithDelegate work?
Re: how does canCloseDocumentWithDelegate work?
- Subject: Re: how does canCloseDocumentWithDelegate work?
- From: Sherm Pendley <email@hidden>
- Date: Sun, 6 Jul 2003 21:36:08 -0400
D'oh!
Correction... The first argument passed to the callback method should be
the document, not the delegate.
On Sunday, July 6, 2003, at 08:01 PM, Sherm Pendley wrote:
- (void)canCloseDocumentWithDelegate: (id)delegate
shouldCloseSelector: (SEL)shouldCloseSelector
contextInfo: (void*)contextInfo {
NSMethodSignature *ms;
NSInvocation *inv;
BOOL shouldClose;
// Do whatever document-specific processing is needed here. If the
document
// is not dirty, shouldClose can be set to YES. If the document is
dirty, you can
// present a sheet or dialog asking if the user wants to save it,
and set shouldClose
// according to the results of that.
// Just to be paranoid, verify that the delegate responds to the
given selector
if ([delegate respondsToSelector:shouldCloseSelector]) {
// Create the invocation object
ms = [delegate methodSignatureForSelector:shouldCloseSelector];
inv = [NSInvocation invocationWithMethodSignature:ms];
// Set the target, selector, and parameters
[inv setTarget:delegate];
[inv setSelector:shouldCloseSelector];
[inv setArgument:&delegate atIndex:2];
The above line should be:
[inv setArgument:&self atIndex:2];
[inv setArgument:&shouldClose atIndex:3];
[inv setArgument:&contextInfo atIndex:4];
// Invoke!
[inv invoke];
}
}
sherm--
Heisenberg may have slept here.
_______________________________________________
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.