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
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
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
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
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
___
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:
>
>>
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?
>
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
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
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
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
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?
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?
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?
•
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
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?
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
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?
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?
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
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
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?
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
> 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
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.
25 matches
Mail list logo