Can't customize toolbar in category

  • I'm having a strange problem...  I added a category on my Controller
    class to separate out all the NSToolbar delegate methods but still have
    access to various ivars in the Controller.  Everything works as expected
    except for customizing the toolbar - when I try to customize, I get the
    following error message in the console:

    2007-05-26 12:12:01.626 ProgName[5608] *** -[Controller
    encodeWithCoder:]: selector not recognized [self = 0x32f040]

    Any ideas on how to fix this?  It's been a while since I've used a
    category for anything, so perhaps I'm forgetting something about the way
    they work.

    I have this init method in my category which is called from the
    Controller's awakeFromNib method.

    - (void)setupToolbars {
    // setup and add the toolbars
    mainToolbar = [[NSToolbar alloc] initWithIdentifier:@"mainToolbar"];
    [mainToolbar setDelegate:self];
    [mainToolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
    [mainToolbar setAllowsUserCustomization:YES];
    [mainToolbar setAutosavesConfiguration:YES];
    [mainWindow setToolbar:mainToolbar];
    }

    Thanks,

    -Ryan
  • Weird - I finally managed to fix the problem I previously posted about
    with the encodeWithCoder problem upon toolbar customization.  It turned
    out to have nothing whatsoever to do with the category I'd added - that
    was a false lead.

    After doing a lot more searching on the Cocoa-Dev list, I came across
    someone who was getting a similar encodeWithCoder error to mine, but his
    was caused by the menu template for his search menu.  Strange.

    <http://lists.apple.com/archives/cocoa-dev/2006/Oct/msg00849.html>

    I went into IB and disconnected my searchMenuTemplate from my
    NSSearchField and voilá no more error upon customization (the search
    field is in a custom NSView which appears in my toolbar).  Weird.  After
    some experimenting, I was unable to figure out what aspect of the menu
    template was causing this, so I just created a new one from scratch,
    added all the menu items to make it the same as the old one, re-hooked
    it up, and now it works.  What the heck?!

    Anyone know what I'm missing here?  It works now, so I guess it's not a
    huge deal, but this is really strange...

    Hope this helps someone else out there!

    -Ryan

    > I'm having a strange problem...  I added a category on my Controller
    > class to separate out all the NSToolbar delegate methods but still have
    > access to various ivars in the Controller.  Everything works as expected
    > except for customizing the toolbar - when I try to customize, I get the
    > following error message in the console:
    >
    > 2007-05-26 12:12:01.626 ProgName[5608] *** -[Controller
    > encodeWithCoder:]: selector not recognized [self = 0x32f040]
    >
    > Any ideas on how to fix this?  It's been a while since I've used a
    > category for anything, so perhaps I'm forgetting something about the way
    > they work.
    >
    > I have this init method in my category which is called from the
    > Controller's awakeFromNib method.
    >
    > - (void)setupToolbars {
    > // setup and add the toolbars
    > mainToolbar = [[NSToolbar alloc] initWithIdentifier:@"mainToolbar"];
    > [mainToolbar setDelegate:self];
    > [mainToolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
    > [mainToolbar setAllowsUserCustomization:YES];
    > [mainToolbar setAutosavesConfiguration:YES];
    > [mainWindow setToolbar:mainToolbar];
    > }
    >
    > Thanks,
    >
    > -Ryan
previous month may 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