Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplaying a to-many relationship in a view (NSTableColumn) via Binding and Value Transformer
    primarykey
    data
    text
    <p>I have an entity Tag (in core data) that have some attributes and a to-many relationship named "aliases".</p> <p>My ArrayController is "bind" in Xcode to:</p> <pre><code>Parameters-&gt;Managed Object Context = File's Owner.managedObjectContext </code></pre> <p>It work OK for all Attributes, the others columns present the correct values.</p> <p>In one column I try to "display" this to-many relationship. If I do it naively and bind the Value of my NSTableColumn to my ArrayController.arrangedObjects.aliases (like all other attributes) I get this on the screen:</p> <blockquote> <p>Relationship fault for (), name aliases, isOptional 1, isTransient 0, entity Tag, renamingIdentifier aliases, validation predicates ( ), warnings ( ), versionHashModifier (null), destination entity TagAlias, inverseRelationship tag, minCount 0, maxCount 0 on 0x10053db10</p> </blockquote> <p>It seems to be some kind of CoreData proxy for the relationship...</p> <p>I then build a subclass of NSValueTransformer:</p> <pre><code>@interface tagAliasesToStringTransformer : NSValueTransformer + (Class)transformedValueClass; + (BOOL)allowsReverseTransformation; - (id)transformedValue:(id)value; @end </code></pre> <p>and tried to use it as a Value Transformer in the binding. But I'm lost in my implementation:</p> <pre><code>@implementation tagAliasesToStringTransformer + (Class)transformedValueClass { return [NSString class]; } + (BOOL)allowsReverseTransformation { return NO; } - (id)transformedValue:(id)value { if (value == nil) return nil; ... } @end </code></pre> <p>In the method transformedValue:, value is of class '_NSFaultingMutableSet' and I don't know how to get a Set/Array of the aliases or anything useful.</p> <p>The goal is to build a NSString of the concatenation of each alias. Something like:</p> <blockquote> <p>aTag : alias1 alias2 alias3 ...</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload