Re: Cocoa Documentation on NSFormatter
Re: Cocoa Documentation on NSFormatter
- Subject: Re: Cocoa Documentation on NSFormatter
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sun, 16 Dec 2001 10:28:01 +0100
Le samedi 15 dicembre 2001, ` 11:46 , Ondra Cada a icrit :
TLR> Anyway, in my own subclass of NSFormatter, getObjectValue... is
called
TLR> first with the string I typed in the text field. I return a custom
TLR> object which is here a subclass of NSObject, say myObjectClass. SINCE
TLR> the declaration declares the object of type 'id', I presume that any
TLR> object should be convenient, but it is NOT.
But it _IS_, so far as the formatter is concerned!
Quite another question is _how you use the thing_. I guess you probably
use
it as some cell's formatter (after all, a vast majority of formatters is
used
that way). *IF* you do that, though, you should have looked at the NSCell
docs, which cleanly declare
-(void)setObjectValue:(id <NSCopying>)object
Therefore:
- it is quite all right to return *ANY* id from the NSFormatter method as
'obj';
- THOUGH, of course, you have to consider how it will be used!
- and if it happens to be used as an object value of a cell, it HAS to
conform to NSCopying.
Ok, I understand the point. The formatter can return anything, but cells
use only NSCopying objects. That's why my code doesn't work, since I
format a text field.
It is documented nicely and well.
Humm. I certainly wouldn't say that! I still consider that the chain of
itneraction between cells and formatters is not really explained. Moreover,
since a formatter is primarily intented to format cells (ok it is not
requirement, but it is 99,99% of its use, no?), there should be at least a
note saying that objects returned by formatters ought to implement
NSCopying in that case.
Generally speaking, I feel that the doc need more 'transversal'
information, in particular for interactions between classes, like
Foundation and AppKit. Foundation can be used alone, but is certainly very
frequently used with AppKit, so more information here should be useful.
Anyway thanks for having pointed this relation for me. I didn't suspect
that at all.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.