• 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
Menu Mystery
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Menu Mystery


  • Subject: Menu Mystery
  • From: Jerry LeVan <email@hidden>
  • Date: Fri, 11 Jun 2004 00:10:41 -0400

I have a dynamically built menu (with submenus) that reflects
the contents of a file directory hierarchy.

I want to, at the users request, refresh the menu. I am trying
to do this by first deleting the menu and then calling the
rebuild routine.

Regrettably there is something that I do not understand. The
tear down code fails for reasons that are not clear to me...

Here is the destroy code:
-(IBAction) updateScriptsMenu:(id)sender
{
int i;
NSMenu * zMenu = [sender menu];
int menuSize = [ zMenu numberOfItems];
NSLog(@"menusize: %d",menuSize);
for( i=3 ; i< menuSize ; i++) {
NSLog(@"I:%d Item:%@",i, [[zMenu itemAtIndex:i] title]);
[zMenu removeItemAtIndex:i];
}

}

The log function shows the correct number of top level items (
I only have one submenu at this point...)

The second log shows:

2004-06-10 23:59:54.444 BiggerSQL[3668] menusize: 27
2004-06-10 23:59:54.444 BiggerSQL[3668] I:3 Item:allCategories.sql
2004-06-10 23:59:54.445 BiggerSQL[3668] I:4 Item:booktown.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:5 Item:ChecksWithEmbeddedTotals.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:6 Item:Customers.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:7 Item:describe.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:8 Item:FastTotalByCategory.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:9 Item:GrandTotalandSubTotal.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:10 Item:running total.sql
2004-06-10 23:59:54.446 BiggerSQL[3668] I:11 Item:RunningTotalChecksSlow.sql
2004-06-10 23:59:54.447 BiggerSQL[3668] I:12 Item:runningtotalsviaoids.sql
2004-06-10 23:59:54.447 BiggerSQL[3668] I:13 Item:SubTotals2004.sql
2004-06-10 23:59:54.447 BiggerSQL[3668] I:14 Item:tax.sql
2004-06-10 23:59:54.447 BiggerSQL[3668] *** Assertion failure in -[NSMenu itemAtIndex:], Menus.subproj/NSMenu.m:638
2004-06-10 23:59:54.546 BiggerSQL[3668] Invalid parameter not satisfying: (index >= 0) && (index < (_itemArray ? CFArrayGetCount(_itemArray) : 0))


The Items are not being removed in the proper order and the submenu is skipped over,
each time I invoke the function about half the items are removed... ( I want to
keep the first three items, thats why the index starts at three.)

It is late here, am I overlooking something obvious?

Jerry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Menu Mystery
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: Ordered NSDictionary
  • Next by Date: Re: cocoa-dev digest, Vol 2 #4343 - 13 msgs
  • Previous by thread: Re: Ordered NSDictionary
  • Next by thread: Re: Menu Mystery
  • Index(es):
    • Date
    • Thread