• 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
[Q] Will the be any problem in implementing an NSArray method using fast enumeration?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] Will the be any problem in implementing an NSArray method using fast enumeration?


  • Subject: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?
  • From: JongAm Park <email@hidden>
  • Date: Thu, 30 Jun 2011 11:59:01 -0700

Hello,

I wrote a method for NSArray.

- (NSArray *)objectsForKey:(id)key
{
	NSMutableArray *objectsArray = [NSMutableArray arrayWithCapacity:10];

	for( id item in self )
	{
		[objectsArray addObject:[item objectForKey:key]];
	}

	return [[objectsArray copy] autorelease];
}

What I'm curious is if it is OK to use fast enumeration to implement an NSArray method itself.
Because the mechanism for fast enumeration is already there, I basically think it will be OK.
However, wouldn't it better to rely on the most fundamental mechanism like objectAtIndex:?
I found someone's implementation here at http://svn.opengroupware.org/SOGo/inverse/trunk/SoObjects/SOGo/NSArray+Utilities.m
Approaching such a way looks reasonable to me, because it should work whatever underlying mechanism is supported by Objective-C.

Will there be any good/bad aspect in using fast enumeration in this case?

Thank you.


_______________________________________________

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: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: dealloc and scarce resources
  • Next by Date: Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?
  • Previous by thread: Scaling CALayer produces blurry/distorted text
  • Next by thread: Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?
  • Index(es):
    • Date
    • Thread