• 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
NSTokenField: binding + disappearing tokens
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTokenField: binding + disappearing tokens


  • Subject: NSTokenField: binding + disappearing tokens
  • From: Andrew Shamel <email@hidden>
  • Date: Fri, 12 Feb 2010 16:50:20 -0800

Hi there!

I am having a bizarre problem with NSTokenField.  In Interface Builder, having bound the field's "value" binding to an NSArrayController containing NSManagedObjects, and passing the value through a ValueTransformer, the field's tokens show up, displaying the proper values.  However, when the mouse enters and then leaves, the tokens disappear (unless the mouse leaves by the top of the field).  Weird, right?  I can find no reason why this should be so.

Any thoughts would be vastly appreciated!

Peace,

andy shamel

————————————————————————

Here are the configurations:

Relevant Core Data Entity info

Name: "Character"
Relationship: named "seniorArtisan" to-one, connected to "Character"

The NSArrayController is set to Entity mode, with the Character entity.  Prepares content, managedObjectContext bound to App Delegate

The NSTokenField is bound in Interface Builder with default options to the above NSArrayController, Controller Key: "selection", Model Key Path: "seniorArtisan", and Value Transformer: TokenRelationshipTransformer

Here's the TokenRelationshipTransformer's code:

+ (void)initialize
{
	[TokenRelationshipTransformer setValueTransformer:[[[TokenRelationshipTransformer alloc] init] autorelease] forName:@"TokenRelationshipTransformer"];
}

+ (Class)transformedValueClass
{
    return [NSArray class];
}

+ (BOOL)allowsReverseTransformation
{
    return YES;
}

- (id)transformedValue:(id)value
{
	NSLog(@"transforming value: %@",value);
	if ([value isKindOfClass:[NSSet class]]) {
		return [value allObjects];
	} else if (value != nil) {
		return [NSArray arrayWithObject:value];
	} else {
		return nil;
	}
}

- (id)reverseTransformedValue:(id)value
{
	NSLog(@"reversing value: %i",[value count]);

	if (value == nil) {
		return nil;
	} else if ([(NSArray *)value count] == 1) {
		NSLog(@"reverse transforming 1");
		return [(NSArray *)value objectAtIndex:0];
	} else {
		NSLog(@"reverse transforming more than 1");
		return [NSSet setWithArray:value];
	}

	return value;
}

_______________________________________________

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

  • Prev by Date: Re: @distinctUnionOfArrays problem
  • Next by Date: Youtube video upload ussue
  • Previous by thread: Re: @distinctUnionOfArrays problem
  • Next by thread: Youtube video upload ussue
  • Index(es):
    • Date
    • Thread