On 20 Dec 08, at 02:16, Graham Cox wrote:
On 20 Dec 2008, at 8:05 pm, Andrew Farmer wrote:
However, I think you've overengineering things here. The standard runtime introspection methods, like [NSObject class] and [NSObject isKindOfClass:], should be more than enough to implement this sort of functionality.

You might be right about the overengineering, but -class and - isKindOfClass: can't be used on methods, only on objects you already have. If you have an object that has a property setter, e.g.

- (void)    setColor:(NSColor*) aColor;

and you have a variable selector that can refer to that (but also potentially many other) methods, and an object that might, or might not, be an NSColor*, how do you make sure you don't end up sending that method a string?

Ah... I probably should have explained further. What I was thinking of was a "try first and ask forgiveness" approach - have the calling code attempt to set the property unconditionally, and have the setter throw an exception if the object it's passed is in fact of the wrong type. This isn't any help if you need to *determine* what the desired type is, but it's fine if all you need to be able to do is throw an error when the wrong type of object is passed.
_______________________________________________

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 arch...@mail-archive.com

Reply via email to