Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8285201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:24:27+00:00 2026-06-08T11:24:27+00:00

I have application based on NSDocument (NSPersistentDocument), in application I can create (as usually)

  • 0

I have application based on NSDocument (NSPersistentDocument), in application I can create (as usually) more than one document.

Main document window (based on NSPersistentDocument) has, added IB, toolbar. In code I add to toolbar item (NSToolbarItems) using methods insertItemWithItemIdentifier and - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag.

Code samples:

[_toolbar insertItemWithItemIdentifier:@"addTape" atIndex:2];

and

- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
    NSToolbarItem *item =nil;

    if ([itemIdentifier isEqual:@"addTape"]) {
        item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier];
        item.label = NSLocalizedString(@"Add Tape",@"Add Tape");
        item.paletteLabel = NSLocalizedString(@"Add Tape",@"Add Tape");
        item.toolTip = NSLocalizedString(@"Adds new tape",@"Adds new tape");
        item.image = [NSImage imageNamed:@"NSAddTemplate"];
        item.target = self;
        item.action = @selector(addTape:);
        item.tag = 101;         
    }
}

Everything is correct until I have opened only one document. When I open second document (or create new document) on first document window toolbar items are doubled (after opening third document, items are tripled on first window and doubled on second, and so on).

Edit: I noticed, that itemForItemIdentifier is called on each window, everytime I try to add toolbar item. In example: if I have two windows (two opened document) and on one I try to add one button itemForItemIdentifier is called two times.
It is strange to me, because every document has own toolbar with delegate set only to this document.

I don’t have any idea what I have done wrong. Maybe someone will point me where I made a mistake.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:24:29+00:00Added an answer on June 8, 2026 at 11:24 am

    I found solution: I cannot use tooolbar created from nib, because each created this method toolbar has this same identifier. When I created toolbars in code, using different identifiers, the problem has gone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSDocument based application with a nib that represents the visual document.
I have a document-based application and I have sub-classed NSDocument and provided the required
I have a document-based Cocoa application that has to start up a sub-process before
I have one legacy web application based on struts2 (primarily using annotation). While debugging
I have a WorldWind application build based on the Java SDK. It has a
I have a UINavigationBar based application - only a one navigation bar that is
I have an view-based application where the user can do a lot of customization
I'm new to Mac programming and I'm working on a document-based application. My NSDocument
I have a application developed based on Compact Framework 1.0. I can run it,
Hello I have application based on data retrieved over internet... How can I handle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.