iDevGames Forums
Newbie Cocoa query - setTitle: at window init - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Newbie Cocoa query - setTitle: at window init (/thread-4799.html)



Newbie Cocoa query - setTitle: at window init - sealfin - Nov 14, 2005 09:48 AM

Okay, I'm pretty much fluent in C/C++, but I've just started learning Objective-C and Cocoa - I've gone through the "currency converter" tutorial on Apple's pages without any headaches - and I've started to play with the language/API, liking what I'm seeing (also liking the documentation for Cocoa in Xcode) - that's my level of knowledge, so onto the query...

Building on the "currency converter" tutorial, I'm trying to call setTitle: at window init for the main window of the project (to change it to a random string from a file) - I thought this could easily be accomplished by overriding the init method of the NSObject subclass created for the"currency converter" tutorial, but the init method doesn't seem to be called until the first event in the window (i.e. I click a button, et al) - and even then the call to setTitle: doesn't execute, even though my debugging printf() call in the init method is called - any suggestions as to what I'm doing wrong, and a solution? Annoyed

Secondly, setWhateverValue: doesn't seem to work with an NSTextField, even though it is used in the "currency converter" tutorial - I'm having to use setTitleWithMnemonic: instead, with NSString <- C string/number conversion - any suggestion as to what I'm doing wrong here? Annoyed


Newbie Cocoa query - setTitle: at window init - maaaaark - Nov 14, 2005 10:14 AM

Is that window defined in the .nib file? Is this a NSWindow subclass? If you are subclassing NSWindow, is the window in the .nib file defined as your NSWindow subclass?

Are you wiring your GUI objects in your .nib correctly?


Newbie Cocoa query - setTitle: at window init - Taxxodium - Nov 14, 2005 10:16 AM

answer


Newbie Cocoa query - setTitle: at window init - akb825 - Nov 14, 2005 10:32 AM

Why are you subclassing? Just put it in the main class with your other methods, make sure it knows about the window, and put an awakeFromNib method in there. I personally think subclassing is a bit overboard for something such as this. :shrug: