Bindings to display an NSArray of NSStrings as a single NSString?

  • This seems like it would be common enough, to me, that it would have
    bindings for it.  I can't find anything, and am thinking I will write
    an NSValueTransformer to do this (also thought there might be a value
    transformer for this, but no).  Am I missing something?  I thought
    that there should be either a <values....> operator, or a
    patternValue binding, or an NSValueTransformer to do this, but I
    haven't found anything.  I thought I might be able to get something by
    using <values....>, or something similar, but that
    wouldn't work either.

    Dustin
    KC9MEL
  • Bindings are made fpr entities (not only core data entiities, but
    entities). It is a *Key-Value*-Technologie. Strings have no
    properties, no keys, are not entities.

    Maybe you can fake it, if you add a category to the strings:
    @implementation NString( MirrorAddition )
    - (NSString*)reflection { return self; }
    @end

    using reflection as the model key path. But propably it is a design
    problem.

    Amin

    Am Mo,04.08.2008 um 19:32 schrieb Dustin Robert Kick:

    > This seems like it would be common enough, to me, that it would have
    > bindings for it.  I can't find anything, and am thinking I will
    > write an NSValueTransformer to do this (also thought there might be
    > a value transformer for this, but no).  Am I missing something?  I
    > thought that there should be either a <values....> operator,
    > or a patternValue binding, or an NSValueTransformer to do this, but
    > I haven't found anything.  I thought I might be able to get
    > something by using <values....>, or something
    > similar, but that wouldn't work either.
    >
    >
    > Dustin
    > KC9MEL

    Amin Negm-Awad
    <negm-awad...>
  • On Mon, Aug 4, 2008 at 6:32 PM, Dustin Robert Kick <mac_vieuxnez...> wrote:

    > This seems like it would be common enough, to me, that it would have
    > bindings for it.

    You could add a category to NSArray...

    @implementation NSArray (ArrayOfStringsAsSingleString)
    - (NSString *)arrayOfStringsAsSingleString { return [self
    componentsJoinedByString:@", "]; }
    @end

    ...and then bind to "values.arrayOfStringsAsSingleString".

    Hamish
  • yes, indeed, that does seem to be the simplest solution, thanks.

    Dustin
    KC9MEL

    On Aug 5, 2008, at 8:14 AM, Hamish Allan wrote:

    > On Mon, Aug 4, 2008 at 6:32 PM, Dustin Robert Kick <mac_vieuxnez...>
    >> wrote:
    >
    >> This seems like it would be common enough, to me, that it would have
    >> bindings for it.
    >
    > You could add a category to NSArray...
    >
    > @implementation NSArray (ArrayOfStringsAsSingleString)
    > - (NSString *)arrayOfStringsAsSingleString { return [self
    > componentsJoinedByString:@", "]; }
    > @end
    >
    > ...and then bind to "values.arrayOfStringsAsSingleString".
    >
    > Hamish
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today