• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: And another thing I don't quite understand... ;-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: And another thing I don't quite understand... ;-)


  • Subject: Re: And another thing I don't quite understand... ;-)
  • From: John Hörnkvist <email@hidden>
  • Date: Tue, 8 May 2001 17:37:57 +0200

On Tuesday, May 8, 2001, at 05:30 PM, Matt Ridley wrote:

On Tuesday, May 8, 2001, at 04:14 pm, John Hvrnkvist wrote:

return [NSArray arrayWithObjects: NSToolbarCustomizeToolbarItemIdentifier,
[toolItems objectForKey:@"Sample"], nil];

This looks OK --- provided that toolItems really is a dictionary and it has an item identifier for the key @"Sample".

Thanks once again for your reply, John - I appreciate your help.

toolItems is indeed a dictionary, and it does indeed have an item identifier for the specified key. In my method to return all valid items for the toolbar, I simply return [toolItems allkeys]. That works fine. There's definitely an item with the identifier @"Sample" since I create it explicitly.

But returning [toolItems allkeys] is something else --- when you do that you return the keys --- here you're returning the value for the key. It looks like the value for the @"Sample" key is an NSToolbarItem rather than an identifier (which is just a string, IIRC).

So, try doing this instead:
return [NSArray arrayWithObjects: NSToolbarCustomizeToolbarItemIdentifier,@"Sample", nil];

I assume you're getting an exception; what does it look like, and where does it happen?

Not an exception (sorry I wasn't clear on that); I'm seeing a message in the Run tab of Project Builder (same place where NSLog text goes). The message reads:

-[NSToolbarItem isEqualToString:]: selector not recognized

That's an exception which gets caught and reported by an exception handler. (There's always a top level exception handler in applications.)

I'm not using isEqualToString anywhere at all, and the message only appears when I use the "return" statement quoted above. Any thoughts on that?

Yep. You're expected to return a string, but you're returning something else, so when the tool bar calls isEqualToString: (probably when matching the available items to the allowed items) it compares an NSToolbarItem.



Regards,
John Hornkvist


  • Follow-Ups:
    • Re: And another thing I don't quite understand... ;-)
      • From: Matt Ridley <email@hidden>
References: 
 >Re: And another thing I don't quite understand... ;-) (From: Matt Ridley <email@hidden>)

  • Prev by Date: Re: And another thing I don't quite understand... ;-)
  • Next by Date: Re: Something I don't understand...
  • Previous by thread: Re: And another thing I don't quite understand... ;-)
  • Next by thread: Re: And another thing I don't quite understand... ;-)
  • Index(es):
    • Date
    • Thread