• 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: Still having problems with selectors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still having problems with selectors


  • Subject: Re: Still having problems with selectors
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 8 Oct 2002 13:26:08 -0500

At 12:59 PM -0400 10/8/02, email@hidden wrote:
[[allWindowsNSArrayRef objectAtIndex:countOfAllWindows]
canCloseDocumentWithDelegate:self
shouldCloseSelector:
@selector(canCloseDocumentSelector:shouldClose:contextInfo:)
contextInfo:nil];

(I've reformatted the above to be a little easier to read in email.)

You're sending the message canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: to the last item of allWindowsNSArrayRef. The error message you're getting in the log is telling you that NSWindow doesn't respond to this message. It's right; NSDocument is what responds to this message.

That's one problem with this code. Another problem is in your naming conventions. "allWindowsNSArrayRef" has a bunch of redundant information in the name; it should just be something like "allWindows". Similarly, "canCloseDocumentSelector:shouldClose:contextInfo:" should really drop the "Selector:" and become "canCloseDocument:shouldClose:contextInfo:".

A bigger issue with the code: Why do you have an array containing all of your windows? The document-based application architecture will manage things like that for you. You can ask the document controller for the documents in your application,you can ask a document for its window controllers, and you can ask a window controller for its window.

In fact, the document-based application architecture will manage *everything* for you. It'll handle putting up the alert saying there are documents with unsaved changes. It'll also handle letting the user review changes. You can even cause this behavior to be invoked yourself, by sending the shared document controller closeAllDocumentsWithDelegate:didCloseSelector:contextInfo:.

Hope this helps a little. The document-based application architecture is a littel confusing at first, but it sounds like you're on your way to getting the hang of it.

-- Chris

--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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: 
 >Still having problems with selectors (From: email@hidden)

  • Prev by Date: cascading documents
  • Next by Date: _NXPlaceWindow: error setting window shape (1000)
  • Previous by thread: Still having problems with selectors
  • Next by thread: window delegate madness
  • Index(es):
    • Date
    • Thread