How to set the names of NIB items in Xcode 4's Interface Builder? - xcode

Back when Interface Builder was a separate application, one could rename any of the items in a nib file to anything he pleased without any impact on the operation of the final application. It was really nice for keeping things organized and helped a ton with bindings (Company Array Controller, Job Array Controller, and Person Array Controller is much better than having to choose between three items with the same name of "Array Controller").
But unless I'm missing something, this functionality seems to have vanished in Xcode 4. Is it still possible to do this?

It's still possible to do this. IIRC it's in the 'identity' tab of the utilities pane when you have an item in the nib selected.
It's the 'Label' text field in the above screenshot.

Related

macOS: Selecting items from a list by typing on the keyboard

The NSTableView has a feature, called Type Selection, by which the user can type the first letters of a listed item and the view automatically selects the first hit and scrolls to it.
I like to have a similar functionality in a NSCollectionView, where I list images by name.
Before I start writing such code by myself, I wonder if there is an API that can help me with this.
I am especially worred about getting the timing right, as I want to have it use the same timing as the NSTableView does. I imagine that it even changes depending on the user's System Preferences for typing. Also, the NSTableView will select other items with the same typed prefix if waiting long enough. All this can get quite complicated if I want to get it right. I don't want to miss anything.

Is there a way to jump to code for outlets / actions in Xcode (4.4)?

I've been looking at an .xib that someone else set up and it would be really convenient if I could, say, double-click on the properties / methods associated with outlets / actions to jump to the actual code where those are declared / defined. I've tried everything I can think of but so far to no avail. Am I right that there's no way to do that...?
To illustrate, say I've got a UIButton for doing a "reset". When I right-click on that in the Interface Builder (this is Xcode 4.4) I might see that there's an associated outlet called "resetButton" and an action mapped to "onReset". From what I can tell, the only way to find the associated code is to manually type those property / method names into a search box and look for that in the associated .h / .m (e.g. using the Project Navigator search). In some cases, I'm hitting the same names multiple times in different files then having to figure out which one is for the object that I'm actually interested in.
Is there some trick that I could use to jump to the code that I'm not seeing?
ETA

Are hierarchies possible inside a Cocoa popup menu?

I was just wondering if it is possible to create a drop down or popup menu with a hierarchy? The application I am currently working on tracks Assignments, Courses, and Subjects. When the user creates an Assignment they will need to be able to select a Course that it belongs to from a drop down but I also wan't the drop down to be organized a little bit by having headers so the user can easily see what Subject that Course belongs to.
Example:
Select Course: [drop down below]
- Life
--Chores
--Eating
--Vacations
- Math
--Algebra
--Calculus
Etc...
Not the best example but the entries "Life" and "Math" would be bold and unselectable and all of the others would be regular menu items. Does anyone have any suggestions? Let me know if you need more information on what I am trying to do.
Yes, if you build them manually in code or in Interface Builder. No, if you're using Bindings.
NSPopUpButton takes an NSMenu full of NSMenuItems.

How to know which NSTableView opened a Contextual Menu?

I have 5 NSTableView's instances that have the same contextual menu. When I get the message that the menu has been clicked I need to know which table sent it. I've checked the NSMenu documentation but I don't seem to find a way to check which of the tables opened the menu..
I'm thinking of subclassing NSTableView and send a message to the delegate on menuForEvent, would that be the best way?
UPDATE:
Thanks Joshua, I,am using 5 tables to display a 5 day week task planning. Each table represents a week day, and I added the contextual menu for adding and removing tasks. So when a user clicks "add task" on a week day I need to know which one. I've got it working by subclassing tableview and sending a message to the delegate when the menu is opened. In this manner my controller knows which of the tables was the last to call the menu.
But it doesn't seem to me like the best implementation to get this, maybe is like you said the problem lies on the UI, what do you think?
Jose.
I don't see a way to get this information. Menus aren't "attached" to anything; they're displayed in a location. Your -menuForEvent: override might work but it gives me the willies.
While this isn't an answer to your question, I confess my first reaction is "why do you have multiple tables with exactly the same menu?" This strikes me more as a UI issue. One would think a contextual menu would be pretty specific to the specific kind of thing (or view thereof) that it represents. That begs the question: why do you have 5 table views that all have exactly the same context? If all 5 tables represent things that are controlled in the same way by the (presumably) same controller, it's highly likely there's a better way to represent your "collection of things" than 5 separate tables.
I'm making a lot of assumptions, granted, but my curiosity is getting the best of me, I suppose. :-)

What is the name of this Mac OS X control?

Does this control have a name? Or is it just a bunch of simple controls merged together? If so, what controls are they?
http://img8.imageshack.us/img8/3002/picture2xrb.png
It looks like an NSTableView with an a custom cell type and no column header. Have a look at the documentation for NSTableView's tableView:dataCellForTableColumn:row:. For columns which have the same type for all rows you may also set the cell class in interface builder.
I doubt the search box is part of the same control.
You could open the Application's Nib file to see what is in there. Look inside the application bundle. If the application is called Example then you should be able to find the Nib at Example.app/Contents/Resources/English.lproj/MainMenu.nib.
The best tool for investigating this is fscript, specifically FScriptAnywhere which will let you determine the class and much other information about any visual element of any Cocoa program (and do a lot of other interesting things with Cocoa programs).
In addition to what toholio said, an easy way to get the look and feel of the bottom button bar is with BWToolkit.

Resources