Re: NSScriptCoercionHandler ?
Re: NSScriptCoercionHandler ?
- Subject: Re: NSScriptCoercionHandler ?
- From: Jim Correia <email@hidden>
- Date: Wed, 22 Feb 2006 08:33:12 -0500
On Feb 22, 2006, at 12:09 AM, Dustin Voss wrote:
First, did you write a coercion handler and register it? Is it
actually called?
No, I haven't registered one. I was focusing on the failure case for
starters. Let me restate the question, hopefully with more clarity.
The documentation says:
coerceValue:toClass:
Returns an object of the class toClass representing the value
specified by value.
- (id)coerceValue:(id)value toClass:(Class)toClass
Discussion
Returns nil if an error occurs. The object is autoreleased, so you
must retain it until you are finished with it.
There *does not* appear to be a built in coercion handler for number
to string. (I know there are other ways to do this - this is just an
example.)
If I execute
id input = nil;
id output = nil;
input = [NSNumber numberWithInt: 3];
output = [[NSScriptCoercionHandler sharedCoercionHandler]
coerceValue: input toClass: [NSString class]];
NSLog(@"coerced value = (%p, %p) %@", input, output, output);
The input is returned, thus making the return value
- non-nil
- not a NSString
Those are the only two documented return values - nil or a value of
the class passed in.
Which of the following is broken?
- the documentation
- the implementation
- my understanding of the docs
Thanks,
Jim
_______________________________________________
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