Re: Using bindings with an NSArray of NSStrings ?
Re: Using bindings with an NSArray of NSStrings ?
- Subject: Re: Using bindings with an NSArray of NSStrings ?
- From: Bjoern Kriews <email@hidden>
- Date: Tue, 16 Mar 2004 23:28:38 +0100
On 16.03.2004, at 21:31, Scott Anguish wrote:
Yes, this is an issue... if having just string manipulation is a
significant requirement, please file an enhancement bug.. in the
meantime...
Ok.
You could write a two-way Value Transformer that handles the
conversion of the array of strings to an array of dictionaries in one
direction, and then back again in the other. you'd need to set the
content of the array controller as Handles As Compound Value.
I just tried and I have to ask again:
My Application delegate has a method
- (NSArray *) volumes { return [[NSWorkspace sharedWorkspace]
mountedLocalVolumePaths]; }
The ArrayController is in the Main nib file.
I bind its contentArray to File's Owner and use "delegate.volumes" as
the model key path.
"Handle as compound value" is checked and my Transformer name is given.
The object class is NSMutableDictionary.
The delegate registers the ValueTransformer in its +initialize method
(weird place but the only one I could find where its done early enough
for the same nib).
I think the Transformer is registered fine because when I introduce a
typo
in its name in IB I get an error message when the nib is loaded,
otherwise
it loads fine.
Problem: the transformers methods never get called.
I have put NSLog()s in all its methods.
The program behaves like before, happily showing my NSStrings in the
TableView.
(whose column is still bound to ArrayController.arrangedObjects without
a model key path)
When I change the Transformer to NSUnarchiveFromData I get the
(expected) message
about bytes: not being implemented.
To me it seems as if my Transformer gets checked for availability and
is then completely ignored.
in -awakeFromNib it is visible to +valueTransformerNames.
Lost and appreciating any help.
Thanks, Bjoern
--------------------
Transformer:
--------------------
+ (Class) transformedValueClass {
NSLog(@"tVC");
return [NSMutableArray self];
}
+ (BOOL) supportsReverseTransformation {
NSLog(@"sRT");
return YES;
}
// these are not right yet, but they don't even get called
- (id) reverseTransformedValue: (id) value
{
NSLog(@"reverseTransform: %@", value);
return NSStringFromClass([value class]);
}
- (id) transformValue:(id)value {
NSLog(@"transform: %@", value);
return NSStringFromClass([value class]);
}
--------------------
ApplicationDelegate:
--------------------
+ (void)initialize
{
static BOOL done = 0;
if( done )
return;
done = YES;
NSLog(@"initialize");
[NSValueTransformer setValueTransformer: [[[RealizingTransformer
alloc] init] autorelease] forName: @"Realizing"];
}
- (void) awakeFromNib
{
NSLog(@"awake tr: %@", [NSValueTransformer valueTransformerNames]);
}
- (NSArray *) volumes
{
NSLog(@"volumes called");
return [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.