NSAcceptMisspelledSelectors and - (void)performMethodsUsingFuzzyM ethodNameMatching
NSAcceptMisspelledSelectors and - (void)performMethodsUsingFuzzyM ethodNameMatching
- Subject: NSAcceptMisspelledSelectors and - (void)performMethodsUsingFuzzyM ethodNameMatching
- From: Oliver Donald <email@hidden>
- Date: Mon, 6 Oct 2003 15:09:47 +0100
Hi list,
I was reading a (very funny) article on Stepwise the other day
(
http://www.stepwise.com/Articles/Editorial/2002-04-01.01.html) and came
across the category called NSAcceptMisspelledSelectors. This is a funny
idea, but maybe it would be easy to implement for real as a category?
So your object recieves an incorrectly spelt message like 'compareStrnig:foo
with:bar' and, not understanding, it recieves that message encapsulated via
forwardInvocation:(NSInvocation *)invocation. I guess you can use
[invocation selector] to get the SEL, and hence the garbled method name (is
that correct?) but is there any way to ask an object what methods it
supports and the string for the method name? Like a list of SEL's to compare
with? Am I correct in assuming that Cocoa SEL's contain the method name and
args? How else could you go about implementing such a sheme?
I realise that actually calling the best-guess method would be courting
disaster, but maybe a less invasive approach, like giving the usual
exception together with guesses as to what the user meant, without invoking,
would be helpful? To be honest, I quite like the idea of my programs using
some fuzzy logic to get around syntactic errors, even if they do end up in
hyperspace ;)
Cheers,
Oli
DISCLAIMER: The information contained in this e-mail is confidential and may
be privileged. It is intended for the addressee only. If you are not the
intended recipient, please delete this e-mail immediately.
The contents of this email must not be disclosed or copied without the
sender's consent. We cannot accept any responsibility for viruses, so please
scan all attachments.
The statements and opinions expressed in this message are those of the
author and do not necessarily reflect those of the company. The company does
not take any responsibility for the views of the author.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.