• 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 + contents of an array. No dice, for newb.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings + contents of an array. No dice, for newb.


  • Subject: Re: Bindings + contents of an array. No dice, for newb.
  • From: Shamyl Zakariya <email@hidden>
  • Date: Wed, 4 Apr 2007 13:26:42 -0400

It worked!

Thank you Mike, I really appreciate this. I've been writing Cocoa code since late 2002, but most of my work is graphics/physics written in C++ so my usage of Cocoa has been entirely of the old-school pre- bindings nature ( Objective-C++ GUI atop a C++ core ).

Bindings seem completely orthogonal to how I've done GUI programming traditionally; I have a lot of re-education to go through. In fact, my greatest problem is that I don't even know how to *ask* a bindings question. There's a lot of new terminology I'm going to have to grok to be able to effectively ask questions here.

Thanks again,

email@hidden
	In the same episode, the scientist suggests that the
	debigulation can only be reversed by a rebigulator.
		-- wikipedia


On Apr 4, 2007, at 10:21 AM, Mike Abdullah wrote:

Hi Shamyl, having seen your screenshots, I see what the issue is.

You are correctly observing the array itself so that KVO notifications get sent that an object has been added or removed from the array. However, notice this method:

[self setKeys:
		[NSArray arrayWithObjects:
			@"values",
			@"values.value",
			nil]
		triggerChangeNotificationsForDependentKey: @"output"];

It's "keys" not "keyPaths" , so you can't have the @"values.value" work correctly.

What I suggest you do instead, is bind your text field to values.value. Calling [-valueForKeyPath: @"values.value"] wo;; return an NSArray of NSStrings.

You want to add these strings together, so write an NSValueTransformer whose -transformedValue: method looks something like this:

- (id)transformedValue:(id)value
{
	return [value componentsJoinedByString:@", "];
}

And use that as the value transformer for your new binding. If you post a sample project, I'll happily mod it so you can see.

Mike.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Bindings + contents of an array. No dice, for newb. (From: Shamyl Zakariya <email@hidden>)
 >Re: Bindings + contents of an array. No dice, for newb. (From: Shamyl Zakariya <email@hidden>)
 >Re: Bindings + contents of an array. No dice, for newb. (From: Mike Abdullah <email@hidden>)

  • Prev by Date: [Moderator] EOT Re: embedd artworks..
  • Next by Date: CoreData multithreading question: @synchronized
  • Previous by thread: Re: Bindings + contents of an array. No dice, for newb.
  • Next by thread: Unions in Obj-C Code
  • Index(es):
    • Date
    • Thread