Newbie Cocoa query - setTitle: at window init

Moderator
Posts: 699
Joined: 2002.04
Post: #1
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

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #2
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?
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #3

"When you dream, there are no rules..."
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
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:
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Motion Sensor Query for 3D game iphone-query 1 4,521 Sep 2, 2011 09:26 PM
Last Post: PoseMotion
  Window focus events in Cocoa Jar445 2 5,329 Jan 18, 2009 06:02 PM
Last Post: Jar445
  Newbie question: Cocoa and Carbon - which for what and how to get started? BliTz 3 3,259 Jul 27, 2006 10:07 PM
Last Post: OneSadCookie
  how to init and get a dictionary working kensuguro 4 4,041 Oct 2, 2005 02:33 PM
Last Post: blobbo
  Cocoa: Mouse location while dragging window Fenris 4 5,065 Jul 14, 2005 04:46 PM
Last Post: Fenris