[Pythonmac-SIG] OT: getting at the XML in nib files
Steven Majewski
sdm7g@Virginia.EDU
Thu, 17 Jan 2002 18:06:27 -0500 (EST)
On Thu, 17 Jan 2002, Jack Jansen wrote:
> On Thursday, January 17, 2002, at 02:41 AM, Bob Savage wrote:
>
> > One thing, though. One of the files (objects.nib?) is actually a binary
> > file. It has serialized objects from IB.
>
> Has anyone ever tried using ObjC's introspective features to
> dump out these objects after reading them in? From my short
> exposure to Cocoa I got the impression that this might be
> possible...
You would have to load them before you could inspect them with
the introspection API. I don't think you load these objects
as a NSBundle, but you use NSUnarchiver instead.
However, if I give it a try from Python2.1.2/pyobjc, I get:
>>> runtime.NSUnarchiver.unarchiveObjectWithFile_( './objects.nib' )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pyobjc.error: *** class error for 'NSIBObjectData': class not loaded
So I tried loading AppKit.framework first (guessing that that's
where NSIBObjectData classes hide!) and I got back a
<Objective-C `NSIBObjectData' instance at 27b0e0> object from
the Unarchiver.
I don't see the docs for NSIBObjectData, so I might have to
use the introspection classes to see what methods they have.
However, there's a bunch of stuff I haven't moved over to my
laptop since the upgrade, and I don't have the NeoData introspection
classes. I'll see if I can get them set up to work from Python
again.
BTW: You can load a class browser app and the framework from:
<http://www.neodata-inc.com/Eng/index.html>
( But since the files are serialized object archives and not
frameworks/bundles, you can't use the app directly on the
nib file (I believe) -- which is why I have to do it
from Python after they are unarchived. )
-- Steve