Autosave of programmatically created NSTableColumn in NSTableView? - cocoa

I have an NSTableView created in Interface Builder with some columns. I've set the tableview to autosave its settings (I set the autosave name in the Attributes Inspector and checked Column information). Now I want to add some other columns programmatically, but when I quit the app and relaunch it, these newly added columns disappear and the ones created in Interface Builder reappear.
Googling I found a work-around: changing the width of the added column gets the job done, but there must be a better solution!
EDIT: changing the column width only works sometimes.

Maybe you need to load the autosave data at the applications/NSTableView load?

the position, size and ishidden of a NSTableColumn is autosaved -- using the InterfaceBuilder autosave method. make sure to hit the 'Column Information' checkbox...

Related

Specify editing NSTextField inside NSPopover on appearance

I'm working on an app that presents an NSPopover containing a number of NSTextFields. While I can tab between these fields as I expect, the popover is selecting a particular text field to be in the editing state when it appears, and it's not the field I want to edit; I'd like to be able to define which text field is editing on popover appearance programmatically (or in Interface Builder). How can I do this?
I've set up the appropriate key view loop by connecting IB outlets for all the various text fields involved, and I've hooked up the popover's nextResponder property to the text field I want to edit first, but that doesn't seem to have an effect - the popover will still select its preferred text field instead of mine. The Window Programming Guide suggests that I set the initialFirstResponder outlet of the window to the view I want selected, but an NSPopover is not an NSWindow and has no initialFirstResponder property (unless I'm missing something obvious).
Is there any way to specify which NSTextField I want to be editing when an NSPopover appears?
I think you said you tried using -makeFirstResponder: and passing the text field. This will set the window's firstResponder, but that's not the same as initialFirstResponder and the window must have initialFirstResponder set to something other than nil in order to respect the key view loop. (Source) A slight tweak to what you tried worked for me:
- (void)popoverWillShow:(NSNotification *)notification
{
// Set the window's initialFirstResponder so that the key view loop isn't auto-recalculated.
[[myField window] setInitialFirstResponder:myField];
}
I think you can make this work by setting all the text field's that you don't want to have focus to "selectable" instead of "Editable" in IB, this should leave the one text field you want to start with as the first responder. Then, in your popoverDidShow: method, set them all back to editable, and you should be able to tab between them as usual.

Remove sort order from table header in Interface Builder?

I accidentally clicked on the header of an NSTableView in Interface Builder (Xcode 4.3.2), which caused the header to get highlighted and display a search order indicator for a certain column. I only noticed this after I had already saved and reopened the xib file, so I can't undo it anymore.
Because of this, the NSTableView already has a sort order when my application launches, but I want to leave it to the user to decided whether he wants the table view sorted or not.
How can I undo this change in Interface Builder?
I'm still on IB 3.2.6, but here it works to temporarily remove the Sort Key from the table column. You can restore it afterward.

How to rename controls in IB?

I remember being able to rename controls in IB. But it doesn't seem to work anymore. Does anyone know how to rename the controls in IB? IB seems to default to the text value as the default name. This is not an issue until a text value spans multiple lines. The IB sidebar become unreadable.
http://imgur.com/ljqve.png
On the identity inspector (third tab) there is a value called Label (under identity), you can rename it there.

Can I put a NSDatePicker object in a cell of NSTableView?

Right now I am just using a NSTextCell with a NSDateFormatter, I just wanted to know if this was possible, perhaps by using the .
Thanks in advance!
not without making a bunch of hacking... Apple doesn't provide the date picker cell for the table for some reason. I would keep the date formatter or make it so when the cell is clicked, it pops open the graphical date picker.
I created a menu in the xib file, set the outlet for the cell's menu property to the menu, created a subclass of nsdatepicker, overrode the mouseDown:, and made it display the menu when clicked.

How to access an NSNumberFormatter in a text field cell?

In XCode 3.2.x's Interface Builder this was simple enough, selecting the text cell displayed a small icon for the formatter that could be selected to configure the formatter in the attributes pane.
Now in XCode 4, the formatter icon is gone! If I drag an instance of NSTextField with an NSTextFormatter from the library OR drop and NSTextFormatter into an existing cell there is no way I can figure out to select the formatter to configure it!
Add to this the fact that Core Data entities UI prototype assistant was removed and I would say IB integration into XC4 is half baked at best!
Any luck with this anyone?
you can access the formatter from the jump bar at the top of the window. if you select the component you added the formatter to, click and hold and it will turn into a drop down menu. move to the sub menu and the formatter should show up where you can select it.
it seems that you can treat the whole ui like a cascading set of menus that way.
now removing the formatter, that's a different question...
... which after further looking revealed:
over on the left side of the IB window in xcode4 is a 'dock' containing the icons for file owner, first responder etc. this column is expandable, and when you do so will show a hierarchical view of the nib file. through which you can navigate like the finder.
also, see this article:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/InterfaceBuilder/InterfaceBuilder.html%23//apple_ref/doc/uid/TP40010215-CH6-SW3

Resources