• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
indexing of objects in a subview array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Does a NSView's bounds.size always equal to frame.size?
  • Next by Date: Dynamic data model in Core Data
  • Previous by thread: Re: shared instance and nstableview
  • Next by thread: Re: indexing of objects in a subview array
  • Index(es):
    • Date
    • Thread