NSFormatter stringForObjectValue: (what does parameter refer to?)
NSFormatter stringForObjectValue: (what does parameter refer to?)
- Subject: NSFormatter stringForObjectValue: (what does parameter refer to?)
- From: Jeremy French <email@hidden>
- Date: Sun, 30 Jan 2005 18:51:31 -0500
What object does the "anObject" parameter refer to, in the following
NSFormatter method?
- (NSString *)stringForObjectValue:(id)anObject
The NSFormatter class documentation says the above method, "returns the
NSString that textually represents the cell’s object for display and—if
editingStringForObjectValue: is unimplemented—for editing. First test
the passed-in object to see if it’s of the correct class. If it isn’t,
return nil; but if it is of the right class, return a properly
formatted and, if necessary, localized string."
For example, I created a subclass of NSFormatter, which I named
"MyFormatter". I instantiated MyFormatter in Interface Builder, and
assigned it as the formatter for an instance of a NSTextField.
Now when the stringForObjectValue: method is invoked, the class name of
anObject is NSCFString. This is different from what I expected: I
thought the class name would be NSTextField.
I used respondsToSelector: to determine if anObject responds the
following NSControl methods: doubleValue, floatValue, intValue,
objectValue and stringValue. The anObject responds to the first three
(doubleValue, floatValue, intValue), but not the last two (objectValue
and stringValue).
Questions:
1) Why isn't the class name (of anObject) NSTextField, since the
formatter is assigned to an isntance of NSTextField?
2) Why doesn't XCode 1.5 Help display documentation for NSCFString
class, when that class name is typed in the documentation search box?
3) Why doesn't NSCFString appear in either the Application Kit
Reference or Foundation Reference documentation?
4) Why doesn't anObject respond to objectValue and stringValue, but
does respond to doubleValue, floatValue, intValue?
(Using XCode 1.5 and OS 10.3.7)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden