Am 19.05.2008 um 13:11 Uhr schrieb Peter Duniho:

I just don't see how declaring an interface and then using it is so inferior to an informal protocol that it justifies the entire message-dispatching paradigm, especially given that there are in fact advantages to the former. At best, it's a wash.

This is (part of) a method that handles an AppleScript command send to the application.
One possible argument is the color to be used for display:

- (id)handleDisplayCommand:(NSScriptCommand *)command
{
        NSDictionary *args = [command evaluatedArguments];
        NSString *colorName = [args objectForKey:@"color"];
        NSColor *color;

        ...

        if (colorName) {
SEL colorSelector = NSSelectorFromString([colorName stringByAppendingString:@"Color"]);
                if ([[NSColor class] respondsToSelector:colorSelector]) {
                        color = objc_msgSend([NSColor class], colorSelector);
                }
        }

        ...
}

This way you may use any color name that NSColor supports.
You can even just add colors by declaring a category on NSColor and adding the appropriate method.
No changes required in the code above.

I don't have much experience in C++, Java or C#, so I can't comment on those. But I *do* know, that I like it very much that I'm able to do things like that above.


Andreas
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to