Re: Still can't get NSFormatter working....
Re: Still can't get NSFormatter working....
- Subject: Re: Still can't get NSFormatter working....
- From: Todd Freese <email@hidden>
- Date: Tue, 17 Feb 2009 13:55:49 -0600
Don't you hate when it is something so simple.... My ref to the field
is null, do something came unhooked in IB.
Thanks!
Todd
On Feb 17, 2009, at 10:34 AM, Greg Titus wrote:
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
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email______________________________________________________________________
_______________________________________________
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