Archive for August, 2009

Reminders on UNIX bases

Trying to set up a small Web server for development and testing in a VirtualBox virtual machine on my computer, I installed a text-only Debian. This now requires to look back in my souvenirs if I still have something on how to configure such an environment.

So here below are some tips that may help you solve problems when doing so, and that you may welcome to see took together here… (However, if you find errors or wish to complete them, do not hesitate to do so by commenting the posts.)

First tip: How to identify which services are set to start at launch?
I cannot give you the details right now, but you should surely have a look (understand do a web search) on /etc/rc0.d, /etc/rc1.d and so on. These folders contain links to service binaries set to launch (or not) depending on which configuration the server is launched in (for what I can remember, single-user, text login, graphical login, remote login? etc.).


How to open sheets and start modal sessions?

To open sheets, or start modal sessions for a given window, use the shared instance of NSApplication.

Categories: Cocoa Tags: , ,

How to control the creation of an untitled document at application’s launch?

This is determined by the delegate’s methods for NSApplication:

  • applicationShouldOpenUntitledFile:
  • applicationOpenUntitledFile:
Categories: Cocoa Tags: , , ,

How to partially select content of a NSTextField

When you want to programmatically select the text of a NSTextField, you can simply call the selectText:sender method of  NSTextField. However, it selects the whole text and does not allow you to select only a part of it. For this, you need to access the field editor provided by the window containing your field once it has began managing the field’s text. The solution is provided in the following code:

NSText* textEditor = [window fieldEditor:YES forObject:textField];
NSRange range = {start, length};
[textEditor setSelectedRange:range];

window is the window containing your field, textField.

This requires the field editor to be managing your field, what can be done simply by previously selecting the whole text of the field using the selectText:sender method.

Categories: Cocoa Tags: , ,

How to implicitely implement table view sort?

Assuming you have a table view feeded by an array controller, you just have to bind the table view’s “sortDescriptors'” value with the corresponding value of the array controller.

The table view then enables sorting in Cocoa’s classic method: click on the column to sort following the value bound to the column.

Categories: Cocoa Tags: , ,

Old tips’n’tricks

I just found back some of my old notes when I was starting Cocoa development. So, since it was done in an application I do not want to use anymore, but I would like to keep track of them nonetheless, I will share them with you!

So you will get some updates which will be taken from these old notes. This means I may not remember well of it, and help you, should you have a question on one of them… But do not hesitate to try anyway!

%d bloggers like this: