Hello,
I am using cocoa, xcode, and objective c on 10.4.
How can I get code to run when my application starts up? Specifically,
I'd like to fill a NSTableView with the contents of the user's
'Documents' folder when my app starts... any ideas on how to accomplish
this?
I'm not so worried about getting the list of files, but I am not sure
how to do *anything* when the application first starts up. (It would
be possible to perform the action when the window opens, since my app
has only one window, but I don't know how to do this either...)
Mainly a Java programmer, I would like to simply overwrite the
constructor (I believe this would be called init in objective c?) to
perform some tasks after all the components in the window are
themselves initialized. But when I "subclass NSWindow" in Interface
Builder I can't seem to be able to instantiate it... In general, would
I be able to lay out a GUI in Interface Builder in a window that
subclasses NSWindow?
Thanks alot for the help!
-Rob Crowell
matt neuburg - 02 Jan 2006 18:49 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> 'Documents' folder when my app starts... any ideas on how to accomplish
> this?
The app delegate gets a notification (applicationDidFinishLaunching), or
you can use an appropriate nib object's awakeFromNib. If you don't know
things like this, you should read the manual. I'm not being snippy; the
online documentation is very helpful on such matters, and you cannot to
expect to "just know" how to use Cocoa - you must understand the app
framework. Your code runs ONLY in response to a message from the app
framework, so you have to learn what messages you are in line to
receive. In this case, you would have found this little booklet helpful:
<http://developer.apple.com/documentation/Cocoa/Conceptual/AddingBehavio
rToCocoa/Articles/BasicSubclassDesign.html>
m.

Signature
matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/exec/obidos/ASIN/0596005571
Read TidBITS! It's free and smart. http://www.tidbits.com