• 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: Saving NSTextField value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving NSTextField value


  • Subject: Re: Saving NSTextField value
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 31 May 2008 11:32:39 -0700


On 31 May '08, at 11:14 AM, vince wrote:

What's the best way to maintain the value of the textField using Bindings?

I've never worked with user defaults using bindings, but it's really easy to do programmatically:


To store:

[[NSUserDefaults standardUserDefaults] setObject: [textfield stringValue] forKey: @"MyDefault"];

To retrieve:

[textfield setObjectValue: [[NSUserDefaults standardUserDefaults] objectForKey: @"MyDefault"]];

(The reason for using -setObjectValue: in the second line is that, unlike -setStringValue:, it doesn't barf if the value is nil.)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Saving NSTextField value (From: vince <email@hidden>)

  • Prev by Date: Saving NSTextField value
  • Next by Date: Re: Finding the largest value in an NSTreeController?
  • Previous by thread: Saving NSTextField value
  • Next by thread: incorporating mail
  • Index(es):
    • Date
    • Thread