Kristof Dreier — where tech meets text
Willkommen im privaten Blog von Kristof Dreier, Webentwickler und Mac-Enthusiast aus Münster. Thematisch dreht es sich hier um Webdevelopment mit dem Zend Framework, kleinere Einschübe über Cocoa und vielleicht auch mal ein Blick in die Weiten von Ruby on Rails.
Learning by doing
I do not know, how often I used this tiny little sentence. Innumerable times and I oftend tend to say: “Just shut the fuck up and stop getting on my nerves!”
Anyway, this is my way of learning something and so I just started off with “Kraxelmax”. Yeah, I know, I never was and still am really creative in naming my applications. Just suggest another and I might pick it. Sure, you will be mentioned in the credits :).
So, what did I do so far?
Basically just trying things out in order to get familiar with the Interface Builder.
By time I will provide an explanation on how to do certain things, but be aware hardcore-programming-nerds since they will certainly raise your hackles, but hey, it will be easy to understand :)
Starting with sheets
Sheets are simple windows that cover a specific window, avoiding the user does things, he is not supposed to, until the dialog is dismissed.

This was really easy to set up, after figuring out, the sheet has to be a window, not a panel. Stupid me.
Shortened: You place a button on each window and connect them with the open/close method of the sheetController.
Add two instance variable declarations to your header file.
IBOutlet id mainWindow;
IBOutlet id clientSheet;
Open your controller and type in following code for the open-method:
- (IBAction)openSheet:(id)sender
{
[NSApp beginSheet:clientSheet
modalForWindow:mainWindow
modalDelegate:self
didEndSelector:NULL
contextInfo:nil];
}
beginSheet takes the sheet (clientSheet) as an argument and attaches it to the main window.
The modalForWindow puts mainWindow into modal mode, which means, the user can not interact (click, close, etc) with our main window.
didEndSelector and conextInfo are not relevant at the moment.
Next: the close-method:
- (IBAction)closeSheet:(id)sender
{
[clientSheet orderOut:nil];
[NSApp endSheet:clientSheet];
}
This is pretty self-explanatory. Tell the clientSheet to orderOut (go away!) and end the sheet.
Easy, huh?
External links
- Working with sheets
- dev.Floriansweb (german)
Miriam
Mär 21, 12:45
Martin sagt, du hättest gern dein Englisch kritisiert? :) Also ich bin ja kein richtiger expert, aber für mich klingt dieser Text super (mit dem “stupid me” haste mich gekriegt ;) ) – nur eine Sache: Bitte Kommas fast immer vermeiden! Die Engländer haben eine regelrechte Aversion gegen Kommas und setzen sie nur im alleräußersten Notfall! Ich hab mich so daran gewöhnt unverständliche ellenlange Sätze ohne Komma auseinanderzuklamüsern dass mich fast jedes Komma im Englischen irritiert… ^^
Martin
Mär 25, 03:09
Völlig richtiger Einwand, Komma ziwschen Haupt- und Nebensatz, Aufzählung und bei wörtlicher Rede. Rest sind meist Spezialfälle, an die man sich ranwagen kann, wenn man Lust hat. Im Zweifel ist Weglassen immer richtig. Und mache niemals ein Komma vor “that”. :)
Sonst liest sichs gut, nicht viel Erwähnenswertes, außer
“Shortened” -> “In short” oder “to cut things short” und das es hier mal nicht eleganter ist das that wegzulassen bei
“This was really easy to set up, after figuring out that the sheet has to be a window, not a panel.”
Aber ich glaube ich bleibe erst mal bei unserer Sprache der Wahl auf der Uni: Java. :)