• 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: Bindings Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings Help


  • Subject: Re: Bindings Help
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 23 Sep 2008 11:21:34 -0700

On Sep 23, 2008, at 10:22, Eric Lee wrote:

Using bindings, how do you add an object (a textfield's string to be specific) to a NSMutableArray so that a table view can show the object?


You need to modify the array in a KVO-compliant manner, which means the array needs to be a property of some object in your data model. Then use:

[[myDataModelObject mutableArrayValueForKey: @"myArray"] addObject: newString];

In the simplest case, the array can just be an instance variable of the data model object, since KVC is capable of finding instance variables directly:

	@interface MyDataModel ... {
		NSMutableArray* myArray;
		...
	}

Or it can be a genuine property:

	@interface MyDataModel ... {
	...
	}
	@property (...) NSArray* myArray;

with a suitable implementation in MyDataModel.


_______________________________________________

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: Bindings Help
      • From: Ken Thomases <email@hidden>
References: 
 >Bindings Help (From: Eric Lee <email@hidden>)

  • Prev by Date: Re: Adding external library in cocoa app
  • Next by Date: Re: Naming alert panel buttons.
  • Previous by thread: Bindings Help
  • Next by thread: Re: Bindings Help
  • Index(es):
    • Date
    • Thread