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