Chuck wrote:
>Why don't you see for yourself?
Ok. Looking into this NIB more closely (in a project mostly copied from the Hillegass
book but with a couple extra widgets thrown in), I see that the NIB bundle shows up as
a file in Finder (just like a
.app would), but as a directory in Terminal.
Inside it are three .nib files:
Code:
[john ~/dev/osx/RandomApp/English.lproj/MainMenu.nib]$ ls -l
total 32
-rw-r--r-- 1 john staff 334 Oct 15 16:11 classes.nib
-rw-r--r-- 1 john staff 595 Oct 15 16:11 info.nib
-rw-r--r-- 1 john staff 6288 Oct 15 16:11 objects.nib
[john ~/dev/osx/RandomApp/English.lproj/MainMenu.nib]$ file *
classes.nib: ASCII text
info.nib: ASCII text
objects.nib: data
classes.nib only contains
Code:
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {generate = id; seed = id; };
CLASS = Foo;
LANGUAGE = ObjC;
OUTLETS = {textField = id; };
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}
and it seems that it has to do with the Obj-C class (Foo) I created to handle what
happens when you click the buttons. This seems to be simply a roadsign that
says my program will have this object in it at runtime.
info.nib contains
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>1157 32 520 332 1024 0 1024 768 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>1143 405 318 44 1024 0 1024 768 </string>
</dict>
<key>IBFramework Version</key>
<string>291.0</string>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>6R73</string>
</dict>
</plist>
Hmm... I can't make heads or tails out of that.
Finally, objects.nib (the biggest of the three) is binary...
file doesn't
know anything about it.
GetFileInfo doesn't tell me anything interesting.
... Egads! What's this?
/usr/bin/nibtool!
Hmm... it seems to want you to run in on the MainMenu.nib directory rather than on
one of the individual .nib files. Running
nibtool -a MainMenu.nib
yeilds a lot of information, some of which:
Code:
"Object 197" = {
Class = "NSButton";
Name = "NSButton";
alignment = "2";
alternateImageName = "<null>";
alternateTitle = "";
autoresizingMask = "0";
bezelStyle = "1";
bordered = "1";
continuous = "0";
controlSize = "0";
enabled = "1";
font = "{name = System Font; pointSize = 13}";
frameRect = "{{109, 128}, {241, 32}}";
groupedIBObjectID = "<null>";
iBButtonBehavior = "2";
iBButtonType = "1";
imageName = "<null>";
imagePosition = "0";
inset = "2";
isLockedIBObject = "0";
keyEquivalent = "";
keyEquivalentModifierMask = "0";
soundName = "<null>";
state = "0";
tag = "0";
title = "seed random number generator";
transparent = "0";
};
suggests that there is no subclassing going on, rather, just setting a bunch of
member variables for the GUI objects present (in the above case, the "seed" button).
So, it looks to me like IB doesn't subclass anything; I think it just creates
instances of NS* GUI objects as you drag them to your Window/Menu and then sets
up their instance variable values for you according to your preferences (ie.
the text you put into buttons, how large you made things,..). Well, and then
archives those instances for you upon saving the .nib.
As for when you "create" a class in IB (like Foo above), nibtool didn't tell
me anything to suggest that there's anything more going on than simply maybe
creating some sort of stub of Foo (and its methods) so it can keep track of
where the GUI objects are supposed to connect to.