Re: How to set default value for NSTextField from program before window is displayed?
Re: How to set default value for NSTextField from program before window is displayed?
- Subject: Re: How to set default value for NSTextField from program before window is displayed?
- From: Samvel Khalatian <email@hidden>
- Date: Fri, 21 Mar 2008 20:11:16 -0500
Oh, thanks a lot. That resolved my question. Now it works just perfect.
Samvel.
On Mar 21, 2008, at 8:01 PM, Dave Hersey wrote:
If the window with that field is in the controller's nib, which I
think is what you're saying, then nameField will be nil until
awakeFromNib is called. You need to do setup there or later, such as
applicationDidFinishLoading.
Your code looks fine.
- d
On Mar 21, 2008, at 8:51 PM, Samvel Khalatian wrote:
Ok. Application is extremely simple:
Window with two buttons: Next and Prev - and one NSTextField (call
it nameField) where my mates names are supposed to be put. This is
View.
There is an array in program where buddies are kept. This is a
Model. It is basically kept in Controller class because of
application simplicity.
There is a Controller that lets program to interact with Model.
I have connected nameField via IBOutlet with Controller, also
buttons are connected via IBAction to couple methods (like, next
and prev). Controller holds iterator (or internal ID of currently
viewed Buddy Name). I store buddies in NSArray.
So, I startup program and see Window with empty NSTextField
(nameField). Once Next button is clicked next Mate Name is shown.
Prev - previous.
the only thing I do not know is how to set value upon Window Show
up. Trying to use:
[nameField setStringValue: [buddiesArray objectAtIndex: 0]]
in Controller init method. It does not produce desired effect.
Still window shows up with empty nameField.
How to change it initially?
Thanks.
On Mar 21, 2008, at 7:29 PM, Kyle Sluder wrote:
On Fri, Mar 21, 2008 at 8:09 PM, Samvel Khalatian
<email@hidden> wrote:
Field (NSTextField), call it 'mate name', is connected to
Controller
via IBOutlet. Unfortunately setting any value in given text field
from
Controller init method does not produce any meaningful effect
because
it is executed before main window actually displayed resulting in
empty field shown upon window appearance.
You need to elaborate on what's going on with this Controller
object.
You really shouldn't need one; NSArrayController should suffice.
You
would then bind the NSTextField to the array controller's selection
key.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden