• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set default value for NSTextField from program before window is displayed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 19:51:42 -0500

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


  • Follow-Ups:
    • Re: How to set default value for NSTextField from program before window is displayed?
      • From: Dave Hersey <email@hidden>
References: 
 >How to set default value for NSTextField from program before window is displayed? (From: Samvel Khalatian <email@hidden>)
 >Re: How to set default value for NSTextField from program before window is displayed? (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Synchronising across multiple NSUndoManager stacks
  • Next by Date: Re: How to set default value for NSTextField from program before window is displayed?
  • Previous by thread: Re: How to set default value for NSTextField from program before window is displayed?
  • Next by thread: Re: How to set default value for NSTextField from program before window is displayed?
  • Index(es):
    • Date
    • Thread