NSToolbar problem
NSToolbar problem
- Subject: NSToolbar problem
- From: Fjolnir Asgeirsson <email@hidden>
- Date: Tue, 11 May 2004 08:43:46 +0000
I'm having some trouble with NSToolbar.
I get a runtime error which says:
Code:
2004-05-10 12:26:24.449 MacFreeSCI[21361] *** -[AppController
isEqualToString:]: selector not recognized
2004-05-10 12:26:24.450 MacFreeSCI[21361] An uncaught exception was
raised
2004-05-10 12:26:24.497 MacFreeSCI[21361] *** -[AppController
isEqualToString:]: selector not recognized
2004-05-10 12:26:24.498 MacFreeSCI[21361] *** Uncaught exception:
<NSInvalidArgumentException> *** -[AppController isEqualToString:]:
selector not recognized
MacFreeSCI has exited due to signal 5 (SIGTRAP).
Here comes the code that initializes and configures the Toolbar
Code:
I define the required objects in AppController.h
Hir er Kspinn:
Code:
- (id)init
{
[super init];
(NSString *)toolbarIdentifier = @"toolbar";
(NSString *)playIdentifier = @"Play Game toolbar Item";
(NSString *)addIdentifier = @"Add Game toolbar Item";
(NSString *)delIdentifier = @"Remove Game toolbar Item";
(NSString *)modIdentifier = @"Edit Game toolbar Item";
(NSString *)docIdentifier = @"Help toolbar Item";
return self;
}
- (void) makeToolbar
{
(NSToolbar *)toolbar = [[[NSToolbar alloc]
initWithIdentifier:toolbarIdentifier] retain];
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[toolbar setSizeMode:NSToolbarSizeModeRegular];
[toolbar setAllowsUserCustomization:NO];
[toolbar setAutosavesConfiguration:NO];
[toolbar setDelegate:self];
/**********************************************************************
*********************** Here is the cause,
***************************
**********************************************************************/
[window setToolbar:toolbar];
}
- (NSToolbarItem *)toolbar:toolbar
itemForItemIdentifier:itemIdentifier
willBeInsertedIntoToolbar:(BOOL)flag
{
(NSToolbarItem *)toolbarItem = [[[NSToolbarItem alloc]
initWithItemIdentifier:itemIdentifier] retain];
if ([itemIdentifier isEqualToString:addIdentifier])
{
// here I set the label & tooltip
[toolbarItem setToolTip:@"Add a new game"];
[toolbarItem setLabel:@"Add"];
[toolbarItem setPaletteLabel: @"Add Game"];
// Here the toolbar Item image is set
NSImage *addImage = [NSImage imageNamed:@"addItem.png"];
[toolbarItem setImage:(NSImage *)addImage];
// Here the Item is told what it should do when clicked
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(addGame:)];
}
else if ([itemIdentifier isEqualToString:playIdentifier])
{
// here I set the label & tooltip
[toolbarItem setToolTip:@"Play Selected Game"];
[toolbarItem setLabel:@"Play"];
[toolbarItem setPaletteLabel: @"Play Game"];
// Here the toolbar Item image is set
NSImage *delImage = [NSImage imageNamed:@"playItem.png"];
[toolbarItem setImage:(NSImage *)delImage];
// Here the Item is told what it should do when clicked
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(playGame:)];
}
else if ([itemIdentifier isEqualToString:delIdentifier])
{
// here I set the label & tooltip
[toolbarItem setToolTip:@"Remove Selected Game"];
[toolbarItem setLabel:@"Remove"];
[toolbarItem setPaletteLabel: @"Remove Game"];
// Here the toolbar Item image is set
NSImage *delImage = [NSImage imageNamed:@"delItem.png"];
[toolbarItem setImage:(NSImage *)delImage];
// Here the Item is told what it should do when clicked
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(delGame:)];
}
else if ([itemIdentifier isEqualToString:modIdentifier])
{
// here I set the label & tooltip
[toolbarItem setToolTip:@"Modify Selected Game"];
[toolbarItem setLabel:@"Modify"];
[toolbarItem setPaletteLabel: @"Modify Game"];
// Here the toolbar Item image is set
NSImage *modImage = [NSImage imageNamed:@"modItem.png"];
[toolbarItem setImage:(NSImage *)modImage];
// Here the Item is told what it should do when clicked
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(modGame:)];
}
else if ([itemIdentifier isEqualToString:docIdentifier])
{
// here I set the label & tooltip
[toolbarItem setToolTip:@"Show the help file"];
[toolbarItem setLabel:@"Help"];
[toolbarItem setPaletteLabel: @"Help"];
// Here the toolbar Item image is set
NSImage *helpImage = [NSImage imageNamed:@"helpItem.png"];
[toolbarItem setImage:(NSImage *)helpImage];
// Here the Item is told what it should do when clicked
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(showDocs:)];
}
else
{
toolbarItem = nil;
}
return toolbarItem;
}
// This is the allowed set of Items
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:addIdentifier,
delIdentifier,
modIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
docIdentifier];
}
// This is the default set of Items
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:addIdentifier,
delIdentifier,
modIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
docIdentifier];
}
I just don't understand this
-Fjvlnir Asgeirsson
-Aptiva
_______________________________________________
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.