Lefora Free Forum
login join
Loading
537 views

Running code automatically

Page 1
1–4
rookie - member
6 posts

G'day All,

Is it possible to get a block of code to execute  automatically when the application opens?

Cheers,
A.

?
288 posts

Of course.  main() always runs before anything.  For all the objects in your NIB, you'll get an init when the objects are created and awakeFromNib() when they're ready for use (when your outlets have been initialized).

__________________
rookie - member
6 posts

Thanks for that advice.  I'm trying it but not having much luck.  Cocoa is nothing like Python

If I have a text box called txtOut that is defined in my controller module called "controller" and I want to stick a string (eg. @"Hello") into the thing when main() runs using the awakeFromNIB event how do I code it?  Or have I not given you enough info.  I'm never sure how much of the code hinges on other bits.

Thanks again,

A.

?
288 posts



I've written a little program "WeeBoxWithString".  It's no thrills - it simply displays the current time in a string (and updates it every second).

You can download the code from http://clanmills.com/articles/cocoatutorials/WeeBoxWithString.zip

If you're wondering how I made this (in about 5 minutes), you'll find a very similar tutorial at http://clanmills.com/articles/cocoatutorials/Clock.pdf

The code here is slightly different.  If you're puzzled (although I hope you are enlightened), come back and I'll try to help.

I agree that Cocoa is nothing like Python (or Swing or MFC or VB or Win32).  It's very nice and elegant - however I have also found it difficult to learn.  I've written some tutorials which you might find helpful.  "Clock" is the simplest.  http://clanmills.com/articles/cocoatutorials/

__________________
Page 1
1–4

Locked Topic


You must be a member to post in this forum

Join Now!