indexing of objects in a subview array
indexing of objects in a subview array
- Subject: indexing of objects in a subview array
- From: Boyd Collier <email@hidden>
- Date: Tue, 9 May 2006 17:06:37 -0700
In attempting to better understand subviews, I tried two alternative
forms of what would seem to be doing the same thing (see below). In
the nib containing the subviews there are 6 items, and in code not
shown, the 2 forms agree in this regard. However, the first form
indicates the item whose tag is 15 is the last item in subviewArray
(that is, i = 5), while the second form indicates that this item is
the first item in the array (that is, i = 0). No other changes were
made in my code, nor was the nib file altered. Why would the
ordering of objects in subviewArray be different?
[Please understand that I'm just trying to understand what seems to
be an anomaly. I mention that to avoid anyone feeling they need to
scold me for not using an iterator or for looking at tags.]
Boyd
// FIRST FORM
NSArray *subviewArray = [ _groupsNibView subviews];
int i = [subviewArray count];
NSLog(@"number of items in groups subview = %i", i);
while (i)
{
i--;
if ( [[subviewArray objectAtIndex:i] tag] == 15);
break;
}
NSLog(@"the index of the object is %i", i);
// SECOND FORM
NSArray *subviewArray = [ _groupsNibView subviews];
NSLog(@"number of items in groups subview = %i", [[ _groupsNibView
subviews] count] );
int i = 0;
while (i < [subviewArray count])
{
if ( [[subviewArray objectAtIndex:i] tag] == 15);
break;
i++;
}
NSLog(@"the index of the object is %i", i);
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden