• 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
NSArray KVC proxy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArray KVC proxy


  • Subject: NSArray KVC proxy
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 25 Jan 2009 12:54:13 -0800

Consider a class with an array property 'xxxx' implemented KVC- compliantly by the following methods:

	- (NSUInteger) countOfXxxx;
	- (id) objectInXxxxAtIndex: (NSUInteger) index;

(Assume there's no NSArray instance variable backing this property.) So, users of the class can call [valueForKey:@"xxxx"] to get a proxy object that returns the objects in the "array".

Now, the question is: How do I implement a getter? The intention is that it's just a convenience method for getting a proxy:

	@property (readonly) (NSArray*) xxxx;

	- (NSArray*) xxxx {
		return [self valueForKey: @"xxxx"];
	}

but that is a *really* bad idea, because valueForKey: will *first* try calling the 'xxxx' method -- the one it was called from.

As I missing something simple here? It seems like there needs to be an 'arrayValueForKey:' method (parallel to mutableArrayValueForKey:), which checks whether the class implements the indexed accessors before calling the getter, instead of after.


_______________________________________________

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: NSArray KVC proxy
      • From: Jeff Johnson <email@hidden>
  • Prev by Date: Re: CFHTTP +authentication
  • Next by Date: Displaying an NSSet in a Single Table Cell?
  • Previous by thread: Re: Targeting Tiger
  • Next by thread: Re: NSArray KVC proxy
  • Index(es):
    • Date
    • Thread