• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how does canCloseDocumentWithDelegate work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: how does canCloseDocumentWithDelegate work? (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: Speed up drawing of View with multiple NSBezierPaths
  • Next by Date: Help! Broken dev tools...
  • Previous by thread: Re: how does canCloseDocumentWithDelegate work?
  • Next by thread: Notification of any application events
  • Index(es):
    • Date
    • Thread