Efficient hierarchical menu from path?

  • Currently, I'm using NSFileManager to iterate through a items and
    folders to build a menu from a given path, but this has a large memory
    overhead, I'd assume due to the file icons.  I have seen some apps
    that provide hierarchical menus, but use very little memory.  Any
    suggestions as to how to do this?  Is there a way to get the Finder to
    supply this menu?

    Thanks.
  • On Dec 13, 2007, at 8:59 PM, Justin Hawkwood wrote:

    > Currently, I'm using NSFileManager to iterate through a items and
    > folders to build a menu from a given path, but this has a large
    > memory overhead, I'd assume due to the file icons.  I have seen some
    > apps that provide hierarchical menus, but use very little memory.
    > Any suggestions as to how to do this?  Is there a way to get the
    > Finder to supply this menu?

    While I haven't tried this myself it seems that you should be able to
    dynamically create only the parts of the menu that the user actually
    navigates to. You might be able to do that by leveraging the the "-
    menuNeedsUpdate:" NSMenu delegate method (and please see the
    discussion in the docs for that method for additional considerations).

    j o a r
  • I've tried this and it does work pretty well.
    I didn't look at actual memory usage but it never seemed to be a problem
    for me.

    j o a r wrote:
    >
    > On Dec 13, 2007, at 8:59 PM, Justin Hawkwood wrote:
    >
    >> Currently, I'm using NSFileManager to iterate through a items and
    >> folders to build a menu from a given path, but this has a large
    >> memory overhead, I'd assume due to the file icons.  I have seen some
    >> apps that provide hierarchical menus, but use very little memory.
    >> Any suggestions as to how to do this?  Is there a way to get the
    >> Finder to supply this menu?
    >
    >
    > While I haven't tried this myself it seems that you should be able to
    > dynamically create only the parts of the menu that the user actually
    > navigates to. You might be able to do that by leveraging the the
    > "-menuNeedsUpdate:" NSMenu delegate method (and please see the
    > discussion in the docs for that method for additional considerations).
    >
    > j o a r
  • On 2007 Dec, 13, at 22:59, j o a r wrote:

    > While I haven't tried this myself it seems that you should be able
    > to dynamically create only the parts of the menu that the user
    > actually navigates to. You might be able to do that by leveraging
    > the the "-menuNeedsUpdate:" NSMenu delegate method

    Yes, it will work for that.

    > (and please see the discussion in the docs for that method for
    > additional considerations).

    and also be aware that there is a bug in Tiger/Panther: Submenus are
    leaked, which causes a hell of a mess including long pizza wheels and
    mysterious crashes when they send messages to other deallocced
    objects.  I worked around this in my subclass of NSMenu, in -dealloc,
    by looping through all NSMenuItems in -itemArray and sending each a
    setSubmenu:nil.

    This bug has been fixed in Leopard.
  • Jerry Krinock wrote:
    > and also be aware that there is a bug in Tiger/Panther: Submenus are
    > leaked, which causes a hell of a mess including long pizza wheels and
    > mysterious crashes when they send messages to other deallocced
    > objects.  I worked around this in my subclass of NSMenu, in -dealloc,
    > by looping through all NSMenuItems in -itemArray and sending each a
    > setSubmenu:nil.
    Thanks for the info; this tidbit will undoubtedly save me some
    leak-tracking time later ;)
  • On Dec 14, 2007, at 4:22 PM, Jerry Krinock wrote:

    > and also be aware that there is a bug in Tiger/Panther: Submenus are
    > leaked, which causes a hell of a mess including long pizza wheels
    > and mysterious crashes when they send messages to other deallocced
    > objects

      Ack! I completely missed that this was a bug. It's been a recent
    pain in my *** in a current project (pinwheel) that simply doesn't
    happen in Leopard. Thanks for the public mention!

      In response to John Stiles' problem, I'm using exactly the -
    menuNeedsUpdated: approach for a similar problem that allows user to
    select a node in a rat's nest of nested relationships from a context
    menu. Hey, the users asked for it ... ;-)

    --
    I.S.
  • THANK YOU THANK YOU THANK YOU!!!

    That nailed it!

    On Dec 13, 2007, at 10:59 PM, j o a r wrote:

    >
    > On Dec 13, 2007, at 8:59 PM, Justin Hawkwood wrote:
    >
    >> Currently, I'm using NSFileManager to iterate through a items and
    >> folders to build a menu from a given path, but this has a large
    >> memory overhead, I'd assume due to the file icons.  I have seen
    >> some apps that provide hierarchical menus, but use very little
    >> memory.  Any suggestions as to how to do this?  Is there a way to
    >> get the Finder to supply this menu?
    >
    >
    > While I haven't tried this myself it seems that you should be able
    > to dynamically create only the parts of the menu that the user
    > actually navigates to. You might be able to do that by leveraging
    > the the "-menuNeedsUpdate:" NSMenu delegate method (and please see
    > the discussion in the docs for that method for additional
    > considerations).
    >
    > j o a r
    >
    >
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today