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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to