Re: Using runtime functions to match up object types safely when setting properties
Re: Using runtime functions to match up object types safely when setting properties
- Subject: Re: Using runtime functions to match up object types safely when setting properties
- From: Graham Cox <email@hidden>
- Date: Sat, 20 Dec 2008 21:16:51 +1100
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?
KVV works pretty well for this - it also solves another related
situation where I can usefully convert objects to other types in some
cases - but what I still haven't quite worked out yet is how to
*prevent* the situation arising in the first place, in other words,
given a list of methods, and an object class, how to filter out those
methods/properties from a list that can't accept the object.
--Graham
_______________________________________________
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