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

2011-07-01 Thread Gregory Weston
Dave DeLong wrote: You can just do: NSArray *objectsArray = [theArray valueForKey:key]; And it'll do pretty much the same thing (except that it'll call -valueForKey: on each item in the array, and not objectForKey:. However, if the objects are NSDictionaries, that's pretty much the

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

2011-07-01 Thread Mike Abdullah
On 1 Jul 2011, at 12:59, Gregory Weston wrote: Dave DeLong wrote: You can just do: NSArray *objectsArray = [theArray valueForKey:key]; And it'll do pretty much the same thing (except that it'll call -valueForKey: on each item in the array, and not objectForKey:. However, if the

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

2011-07-01 Thread Mike Abdullah
On 30 Jun 2011, at 22:41, Quincey Morris wrote: On Jun 30, 2011, at 13:51, JongAm Park wrote: The rationale behind enumerator pattern is to unify the way to access collection classes no matter what they actually look like. So, enumerator pattern is actually written in index based

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

2011-06-30 Thread JongAm Park
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]]; }

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

2011-06-30 Thread Dave DeLong
Yeah, that should be fine, but it's unnecessary. You can just do: NSArray *objectsArray = [theArray valueForKey:key]; And it'll do pretty much the same thing (except that it'll call -valueForKey: on each item in the array, and not objectForKey:. However, if the objects are NSDictionaries,

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

2011-06-30 Thread Heath Borders
You might also try HBCollections, a series of collections categories I wrote that makes it easy to do stuff like this. https://github.com/hborders/HBCollections -Heath On Jun 30, 2011 2:10 PM, Dave DeLong davedel...@me.com wrote: ___ Cocoa-dev mailing

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

2011-06-30 Thread JongAm Park
Um... Thanks for your reply. The last time I used that was about 5 or 6 years ago, and I wondered yesterday where it went away. :) Thanks for pointing out that method. BTW, my actual question was if it is meant to use fast enumeration in a collection class implementation. Although I tried to

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

2011-06-30 Thread Quincey Morris
On Jun 30, 2011, at 13:51, JongAm Park wrote: The rationale behind enumerator pattern is to unify the way to access collection classes no matter what they actually look like. So, enumerator pattern is actually written in index based iteration wrapped with enumerator pattern. Similarly, I

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

2011-06-30 Thread JongAm Park
Wow.. great information! Thank you very much for sharing your idea! It definitely helped me! JongAm Park On Jun 30, 2011, at 2:41 PM, Quincey Morris wrote: On Jun 30, 2011, at 13:51, JongAm Park wrote: The rationale behind enumerator pattern is to unify the way to access collection