ftp.nice.ch/pub/next/developer/resources/classes/IBMole.README

This is the README for IBMole.s.tar.gz [Download] [Browse] [Up]

First and formost:
	Many thanks to Timothy Bissel for the excellent Mole.tiff!
	
The IBMole publishes InterfaceBuilder's NXApp variable as a distributed object.  From there you can get a list of the documents open in IB and the objects which lie therein, and then manipulate them programmatically.  I've used it to do things like change stringValues in TextFields in IB, and coerce 800+ SmartFields into TextFields (while preserving connections).  You can do anything that you would be able to do from within IB, only you are on the outside.

I typically write short ugly C programs which iterate thru the objects and do whatever is needed.  I have included a couple to get you started.  Until IB has an ASCII format, this is the only way I know of to modify nibs programmatically.  

I haven't explored using the current selection or playing with connections in IB yet.  I don't see why it isn't possible though...

Caveat Emptor:  Using the mole changes things behind IB's (and all of its palettes') back.  It would be really easy to screw up something and obliterate your nib file.  Although I haven't done that I did run into a problem that looked like that:  For a particular palette I was using when I did a saveAll it was relying on using the currentDocument in its archiving scheme and would appear to lose some of its connections until it was saved while it was the current document.  That one really threw me for a loop and is one of the myriad reasons why it took so long to get this onto the net.  The other reasons include changing jobs and moving 2500 miles....

About using the mole, it is really a bad idea to try and send a message that an object may not understand.  You will usually end up with a Distributed Object Exception 11013 or some such number.  I always test to be sure that the object I'm manipulating responds to the message I'm trying to send.

I can be reached as monty@IntuitiveEdge.com should you have any questions or real cool scripts that use the IBMole...

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.