Re: NSToolbar Problems...
Re: NSToolbar Problems...
- Subject: Re: NSToolbar Problems...
- From: Albert Atkinson <email@hidden>
- Date: Wed, 15 May 2002 14:40:16 -0500
Hello!
Thanks for your help! It finally worked, I was putting it in the
wrong class :-) It works now.
Have a great day!
Albert
On Wednesday, May 15, 2002, at 01:52 PM, j o a r wrote:
On Wednesday, May 15, 2002, at 11:05 , Albert Atkinson wrote:
The thing that is not working is, well, the whole thing. The
toolbar is never put in the window. Any suggestions?
Yes. Either but breakpoints in the toolbar delegate methods, and
your setupToolbar method, and run the debugger to see which
methods are called and in which context. Or alternatively, if you
are not so used to using the debugger, put simple NSLog statements
in the same places for the same result.
Do you get any warnings when building? It seems like you have a
category called "MainController (Private)", but no implementation?
That should give you at least one warning, right? Any other
warnings or runtime errors we should know about?
Some suggestions (some of which are certainly not related to your
problem but could be interesting to think about):
0) Are you sure that the window "documentWindow" actually exist
when you use it to assign the toolbar? Try to verify that it is
actually there. This print out should give you the title of the
window if everything is all right:
NSLog(@"documentWindow title: %@", [documentWindow title]);
1) Shouldn't this line read "isEqualToString:"?
if ([itemIdent isEqual: ConnectToolbarIdentifier]) {
Should perhaps be:
if ([itemIdent isEqualToString:ConnectToolbarIdentifier]) {
This could possibly cause the method used to provide the toolbar
items to never return any item.
2) I would have used a simple define instead of a variable for the
constant strings:
static NSString* MyDocToolbarIdentifier = @"My Document Toolbar";
would be:
#define MY_DOC_TB_IDENTIFIER @"My Document Toolbar"
3) I would have avoided using autorelease in the setupToolbar
method. Whenever I can I use a plain release, because if something
goes wrong, it is much easier to debug / troubleshoot.
Replace:
NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:
MyDocToolbarIdentifier] autorelease];
<snip>
[documentWindow setToolbar: toolbar];
With:
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:
MyDocToolbarIdentifier];
<snip>
[documentWindow setToolbar: toolbar];
[toolbar release];
4) You don't need to "fill" the toolbar with flexible space if you
intend to have only a couple of items positioned to the left in
the toolbar. Your default toolbar could have looked like this:
return [NSArray arrayWithObjects: ConnectToolbarIdentifier, nil];
j o a r
_______________________________________________
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.