Re: Cocoa et al as HCI usability problem
Re: Cocoa et al as HCI usability problem
- Subject: Re: Cocoa et al as HCI usability problem
- From: Andreas Mayer <email@hidden>
- Date: Mon, 19 May 2008 20:31:02 +0200
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 (email@hidden)
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:
This email sent to email@hidden