• 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: A few basic questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A few basic questions


  • Subject: Re: A few basic questions
  • From: Brian Webster <email@hidden>
  • Date: Thu, 21 Jun 2001 18:09:59 -0500

On Thursday, June 21, 2001, at 03:48 PM, cocoa-dev-
email@hidden wrote:

Just programming in Cocoa for the first time, and have a few basic
questions. I'm working in Java.

1. Windows-- I'm subclassing NSWindowController, and implement the
WindowWillClose method--I want the window and its controller to both
go away if the window is closed.

I'm not exactly sure what your problem is, as it could be a number of things, and it's further complicated by the differences between ObjC and Java memory management. Firstly, I think you probably want to implement windowDidClose() instead of windowWillClose(), since the window's not really safe to get rid of until it's actually closed. Secondly, instead of just setting window to null, you should call setWindow(null), which should perform the proper releasing of the window. Third, in order to get rid of the window controller itself, you should probably call autorelease() after releasing the window, which will release the controller before the next time through the run loop. I'm a little unsure about all of this, though, since I don't know to what extent Java's garbage collection works in a Java/Cocoa app. Does anybody know of a place where the rules for this are spelled out explicitly?

2. Window autosave--this is probably related to #1, but I want to
forget about the autosave after a window is closed by the user. Will
this happen automatically if the NSWindowController actually gets
unloaded before the app terminates?

Look in your nib file to make sure there is nothing in the Name field of the window. If there is, it will autosave under that name. Otherwise, I don't see any reason why it should be autosaving without explicit instructions in the code. To double check if it's actually autosaving, look in the .plist file for your app in your preferences folder.

3. AppleScript--I've read the basic docs for adding Applescript
support, but I'm a little mystified as to where the top-level objects
are supposed to reside. Say I want to expose a specialObject to
AppleScript. I understand that I'll want accessor methods
specialObject() and setSpecialObject(), but where do I place them?
In the app delegate? I've played with this, and haven't been able to
get it working, but the problem may also lie in my script suite or
terminology.

There is a new file in the ObjC version of the docs that outlines the NSApplicationScriptingDelegation protocol. Implement the method in this protocol to specify what keys your delegate can implement for scripting. I don't know the exact name of the Java version of the method, though.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: A few basic questions
  • Next by Date: Re: help with FSPathMakeRef
  • Previous by thread: Re: A few basic questions
  • Next by thread: Re: Preferences using NSUserDefaults (newbie)
  • Index(es):
    • Date
    • Thread