Re: Finding object array index when iterating through array

2012-03-08 Thread Daniel Vollmer
On 7 Mar 2012, at 12:09, John Maisey wrote: > Hi, > > If the items are unique, how about: > > [array indexOfObject:object]; Congratulations, you have just (depending on NSArray-implementation details) "improved" your loop from from O(N) to O(N^2). Don't do this. > Using a counter is likely b

Re: Finding object array index when iterating through array

2012-03-08 Thread Peter
Am 08.03.2012 um 03:39 schrieb Greg Parker: > On Mar 6, 2012, at 6:19 PM, Marco Tabini wrote: >>> I have an array and I am iterating through it using this technique: >>> for (id object in array) { // do something with object } >>> >>> Is there way to obtain the object's curren

Re: Finding object array index when iterating through array

2012-03-08 Thread Roland King
On Mar 8, 2012, at 9:47 AM, Stephen J. Butler wrote: > On Tue, Mar 6, 2012 at 8:19 PM, Marco Tabini wrote: >>> I have an array and I am iterating through it using this technique: >>> for (id object in array) { // do something with object } >>> >>> Is there way to obtain the

Re: Finding object array index when iterating through array

2012-03-08 Thread Andreas Grosam
On Mar 7, 2012, at 3:35 AM, Conrad Shultz wrote: > On 3/6/12 12:42 PM, Prime Coderama wrote: >> I have an array and I am iterating through it using this technique: >> >>> for (id object in array) { >>>// do something with object >>> } >> >> Is there way to obtain the object's current array

Re: Finding object array index when iterating through array

2012-03-08 Thread Graham Cox
On 07/03/2012, at 2:22 PM, Graham Cox wrote: That was over 28 hours ago. Why is it taking so long for posted messages to show up on the list? It's crazy, because by the time the response arrives, the question has been answered over and over and over again --Graham ___

Re: Finding object array index when iterating through array

2012-03-08 Thread John Maisey
cocoa-dev@lists.apple.com > Subject: Finding object array index when iterating through array > Message-ID: <85e319f7-f507-4dac-b69c-fcff7dea2...@gmail.com> > Content-Type: text/plain; charset=us-ascii > > I have an array and I am iterating through it using this technique: > >>

Re: Finding object array index when iterating through array

2012-03-08 Thread J. C. Allen
On Mar 6, 2012, at 3:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? >

Re: Finding object array index when iterating through array

2012-03-08 Thread Jens Alfke
On Mar 6, 2012, at 6:19 PM, Marco Tabini wrote: > [array indexOfObject:object] should do the trick, though, if you need to do > it at every iteration, keeping a counter may be better. Not if the array contains objects that are equal to one another. (It’s also a fairly expensive method, and the

Re: Finding object array index when iterating through array

2012-03-08 Thread Greg Parker
On Mar 6, 2012, at 6:19 PM, Marco Tabini wrote: >> I have an array and I am iterating through it using this technique: >> >>> for (id object in array) { >>> // do something with object >>> } >> >> Is there way to obtain the object's current array index position or do I >> have to add a count

Re: Finding object array index when iterating through array

2012-03-08 Thread Eric Wing
On 3/6/12, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >> // do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? > > Thanks in advanc

Re: Finding object array index when iterating through array

2012-03-08 Thread Stephen J. Butler
On Tue, Mar 6, 2012 at 8:19 PM, Marco Tabini wrote: >> I have an array and I am iterating through it using this technique: >> >>> for (id object in array) { >>>    // do something with object >>> } >> >> Is there  way to obtain the object's current array index position or do I >> have to add a co

Re: Finding object array index when iterating through array

2012-03-08 Thread David Duncan
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-08 Thread Nick Zitzmann
On Mar 6, 2012, at 1:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-08 Thread Fritz Anderson
On 6 Mar 2012, at 2:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? •

Re: Finding object array index when iterating through array

2012-03-08 Thread Mike Abdullah
On 6 Mar 2012, at 20:42, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? We

Re: Finding object array index when iterating through array

2012-03-07 Thread Graham Cox
On 07/03/2012, at 7:42 AM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-07 Thread Joar Wingfors
If you use a block-iterator, the index is passed as a parameter to the iterator block. Joar On 6 mar 2012, at 12:42, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there

Re: Finding object array index when iterating through array

2012-03-07 Thread Keary Suska
On Mar 6, 2012, at 1:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-07 Thread Kyle Sluder
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-07 Thread Jens Alfke
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: > Is there way to obtain the object's current array index position or do I > have to add a counter? You can add a counter, which is pretty easy. Or you can call -enumerateObjectsAtIndexes:options:usingBlock:, which passes the index as well a

Re: Finding object array index when iterating through array

2012-03-07 Thread Conrad Shultz
On 3/6/12 12:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >> // do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? > You c

Re: Finding object array index when iterating through array

2012-03-07 Thread Seth Willits
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter?

Re: Finding object array index when iterating through array

2012-03-07 Thread Roland King
You have to add a counter. On 7 Mar, 2012, at 4:42, Prime Coderama wrote: > I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do

Re: Finding object array index when iterating through array

2012-03-07 Thread Marco Tabini
> I have an array and I am iterating through it using this technique: > >> for (id object in array) { >>// do something with object >> } > > Is there way to obtain the object's current array index position or do I > have to add a counter? [array indexOfObject:object] should do the trick, t

Finding object array index when iterating through array

2012-03-06 Thread Prime Coderama
I have an array and I am iterating through it using this technique: > for (id object in array) { > // do something with object > } Is there way to obtain the object's current array index position or do I have to add a counter? Thanks in advance.