• 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
Programmatically setting the value of a bound TextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Programmatically setting the value of a bound TextField


  • Subject: Programmatically setting the value of a bound TextField
  • From: Felix Franz <email@hidden>
  • Date: Wed, 1 Mar 2006 15:29:05 +0100

In my program I have NSTextField bound to an object using the "value"- Binding.
I would like to test the functionality in a unit-test. I tried using setStringValue:
of the NSTextField but the bound object is not updated. Do I have to call some
methods before/after changing the value?


For example:

// setup:
NSTextField* textField = [[NSTextField alloc] initWithFrame: NSMakeRect(0,0,100,20)];
id person = [Person personWithName: @"foo"]; // person has "name"


NSObjectController* controller = [[NSObjectController alloc] initWithContent: person];


[textField bind: @"value" toObject: controller withKeyPath: @"selection.name" options: nil]

	// try it out:

	NSString* newName = @"bar";


[textField setStringValue: newName];

STAssertEqualObjects( [person valueForKey:@"name"], newName, nil); // this fails




Is there a better way to test controls using bindings?



Thanks in advance,


felix




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Programmatically setting the value of a bound TextField
      • From: Chris Hanson <email@hidden>
    • Re: Programmatically setting the value of a bound TextField
      • From: mmalcolm crawford <email@hidden>
    • Re: Programmatically setting the value of a bound TextField
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: AddressBook corruption (2)
  • Next by Date: Re: Custom View in NSTableView
  • Previous by thread: Re: AddressBook corruption (2)
  • Next by thread: Re: Programmatically setting the value of a bound TextField
  • Index(es):
    • Date
    • Thread