Re: Still can't get NSFormatter working....
Re: Still can't get NSFormatter working....
- Subject: Re: Still can't get NSFormatter working....
- From: Greg Titus <email@hidden>
- Date: Tue, 17 Feb 2009 08:34:31 -0800
How about take a step back. Is 'nameField' hooked up in IB correctly
so that the formatter is actually being set on a real field? You might
try logging both 'nameField' and '[nameField formatter]' right after
your code to assign it.
Hope this helps,
Greg
On Feb 17, 2009, at 7:57 AM, Todd Freese wrote:
Still can't this NSFormatter to work. It does not seem to be getting
called from my NSTextField.
Here is the formatter:
@implementation FileNameFormatter
- (NSString *)stringForObjectValue:(id)anObject
{
if ([anObject isKindOfClass:[NSString class]]) {
NSString *sourceString = [NSString stringWithString:anObject];
return sourceString;
} else {
return nil;
}
}
- (BOOL)getObjectValue:(id *)obj forString:(NSString *)aString
errorDescription:(NSString **)error
{
if (aString != NULL) {
*obj = [NSString stringWithString:aString];
return YES;
} else {
return NO;
}
}
- (NSAttributedString *)attributedStringForObjectValue:(id)anObject
withDefaultAttributes:(NSDictionary *)attributes
{
return nil;
}
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString
originalSelectedRange:(NSRange)origSelRange
errorDescription:(NSString **)error
{
NSLog(@"formatter called");
return NO;
}
@end
And here is how I assign it to the NSTextField:
FileNameFormatter *fileNameFormatter = [[[FileNameFormatter alloc]
init] autorelease];
[nameField setFormatter:fileNameFormatter];
Any ideas?
Todd Freese
_______________________________________________
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
_______________________________________________
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