• 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: combining two entities to one binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: combining two entities to one binding


  • Subject: Re: combining two entities to one binding
  • From: Keary Suska <email@hidden>
  • Date: Sun, 02 Oct 2011 08:11:45 -0600

On Oct 2, 2011, at 6:05 AM, Koen van der Drift wrote:

> On Oct 1, 2011, at 3:09 PM, Keary Suska wrote:
>
>> Not specifically for NSTextView. Text fields have the "value with pattern" bindings, but no such luck for text views. In such cases I generally have a "dynamic" property of a model object that consists of a pseudo-getter and +keyPathsForValuesAffectingKey.
>
> It actually is a label, so I can use the value with pattern bindings, thanks for pointing that out.
>
> Any idea how to get a hard return between the two values?
>
> %{value1}@  %{value2}@

Unfortunately not in the binding text itself, at least AFAIK. There are a number of ways to do this, the most obvious being adding a method to your model class such as:

- (NSString *)hardReturn
{
	return @"\n";
}

and adding it to your bind pattern. I have to say though, that this begs for a dynamic property as I describe above. It is much more extensible and easier to debug.

If, however, you find that you will need to insert carriage returns in a number of different bindings for a number of different model objects, you might consider using an NSFormatter that, for example, replaces occurrences of the string "\n" with a newline. You could also set a category on NSController for the method above, and have it available for any binding. Many options.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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: combining two entities to one binding
      • From: Koen van der Drift <email@hidden>
    • Re: combining two entities to one binding
      • From: Gerd Knops <email@hidden>
References: 
 >combining two entities to one binding (From: Koen van der Drift <email@hidden>)
 >Re: combining two entities to one binding (From: Keary Suska <email@hidden>)
 >Re: combining two entities to one binding (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: combining two entities to one binding
  • Next by Date: Re: combining two entities to one binding
  • Previous by thread: Re: combining two entities to one binding
  • Next by thread: Re: combining two entities to one binding
  • Index(es):
    • Date
    • Thread