• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using runtime functions to match up object types safely when setting properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Using runtime functions to match up object types safely when setting properties
      • From: Andrew Farmer <email@hidden>
    • Re: Using runtime functions to match up object types safely when setting properties
      • From: "Michael Ash" <email@hidden>
References: 
 >Using runtime functions to match up object types safely when setting properties (From: Graham Cox <email@hidden>)
 >Re: Using runtime functions to match up object types safely when setting properties (From: Ken Thomases <email@hidden>)
 >Re: Using runtime functions to match up object types safely when setting properties (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Using runtime functions to match up object types safely when setting properties
  • Next by Date: Re: Newbie Question: implementing a stack
  • Previous by thread: Re: Using runtime functions to match up object types safely when setting properties
  • Next by thread: Re: Using runtime functions to match up object types safely when setting properties
  • Index(es):
    • Date
    • Thread