Skip navigation.
 
mlRe: Bypassing Interface Builder
FROM : Uli Kusterer
DATE : Thu May 15 07:50:22 2008

Am 14.05.2008 um 16:36 schrieb colo:
> My goal is to make a drawing app from the Drawkit framework but for
> the life of me I just can't get past the use IB but Drawkit does not
> use IB but the books do and swear that I should fiasco! Ah ha ha ha ha
> h haha h  hah aa haa



  I think you're going down the wrong road if you try to avoid using 
IB with Cocoa for now reason beyond: 'IB seems unreasonably complex to 
me'.

  That said, it is very easy to create your own windows and views. 
They're just objects. You can alloc/initXXX any view and window 
object, and then put them together using -addSubview: (Every window 
has a content view to which you add its views). You just need to 
create a controller that takes care of this and takes ownership of the 
objects once they are created (by stashing them away in its instance 
variables), and releases them when they're done.

  If you actually have a NIB-like format and just want to create Mac 
controls that match this, you can even do the hookup like IB does it: 
Use NSSelectorFromString() to turn a string representation of a method 
name into a SEL you can pass to -setAction:, and use an NSDictionary 
to match up objects with the IDs/names you've assigned them in your 
file format (e.g. so you can look up the object to pass to another 
object's setTarget: method). To set IBOutlets, you'd use -
setValue:forKey: (and other Key-Value-Coding methods of NSObject's), 
and there are also methods for hooking up bindings manually.

  I haven't exhaustively looked at all the nooks and crannies, so 
there may be some magic that IB does that's not quite as easy, but 
most of it is covered by the above list. Of course, you need to be 
familiar with how to serialize/unserialize an object graph (in general 
programming terms, not Cocoa-specific) to implement this.

  As to apps like Sketch: NSViews do not support overlapping views 
(well, you can use layer-backed views, sort-of, but IMHO you don't 
want to do that for a drawing app with lots of objcts, you'd prolly 
immediately hit the software fallback of your Graphics Card), so an 
app like Sketch would generally use IB for its UI and one 'canvas' 
view to draw all the shapes themselves, functioning as a sort of 
parallel view hierarchy. Graham's GCDrawKit does it that way already. 
So, you see, they're not mutually exclusive. You can even load several 
NIBs and assemble them at runtime (that's what System Preferences 
does, for example).

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

Related mailsAuthorDate
mlBypassing Interface Builder colo May 14, 16:36
mlRe: Bypassing Interface Builder I. Savant May 14, 17:11
mlRe: Bypassing Interface Builder colo May 14, 17:35
mlRe: Bypassing Interface Builder I. Savant May 14, 17:43
mlRe: Bypassing Interface Builder Andy Lee May 14, 17:50
mlRe: Bypassing Interface Builder colo May 14, 17:53
mlRe: Bypassing Interface Builder I. Savant May 14, 17:58
mlRe: Bypassing Interface Builder David Wilson May 14, 17:59
mlRe: Bypassing Interface Builder I. Savant May 14, 18:01
mlRe: Bypassing Interface Builder I. Savant May 14, 18:05
mlRe: Bypassing Interface Builder Gregory Weston May 14, 18:06
mlRe: Bypassing Interface Builder glenn andreas May 14, 18:13
mlRe: Bypassing Interface Builder Wayne Packard May 14, 18:26
mlRe: Bypassing Interface Builder Andy Lee May 14, 18:37
mlRe: Bypassing Interface Builder Stefan Werner May 14, 18:46
mlRe: Bypassing Interface Builder Bill Bumgarner May 14, 19:00
mlRe: Bypassing Interface Builder Boyd Collier May 14, 19:34
mlRe: Bypassing Interface Builder colo May 14, 19:37
mlRe: Bypassing Interface Builder Julius Guzy May 14, 22:05
mlRe: Bypassing Interface Builder Torsten Curdt May 14, 22:49
mlRe: Bypassing Interface Builder colo May 15, 00:53
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:26
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:41
mlRe: Bypassing Interface Builder colo May 15, 02:14
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 02:15
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:29
mlRe: Bypassing Interface Builder I. Savant May 15, 02:43
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:45
mlRe: Bypassing Interface Builder I. Savant May 15, 02:51
mlRe: Bypassing Interface Builder I. Savant May 15, 02:54
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:02
mlRe: Bypassing Interface Builder Graham Cox May 15, 03:02
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:06
mlRe: Bypassing Interface Builder I. Savant May 15, 03:07
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:08
mlRe: Bypassing Interface Builder I. Savant May 15, 03:09
mlRe: Bypassing Interface Builder I. Savant May 15, 03:15
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:29
mlRe: Bypassing Interface Builder Julius Guzy May 15, 03:35
mlRe: Bypassing Interface Builder I. Savant May 15, 03:37
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:33
mlRe: Bypassing Interface Builder Julius Guzy May 15, 04:36
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:54
mlRe: Bypassing Interface Builder Graham Cox May 15, 05:43
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:50
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:55
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 08:15
mlcocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 15:36
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Paul Bruneau May 15, 15:47
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Uli Kusterer May 15, 16:08
mlcocoaheads frankfurt (was Re: cocoa mentoring) Torsten Curdt May 15, 16:44
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 16:51
mlRe: Bypassing Interface Builder Andy Lee May 15, 17:11
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 18:40
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Dennis Munsie May 15, 19:34
mlRe: Bypassing Interface Builder Paul Sargent May 15, 20:07
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 20:48
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:20
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:30
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 22:32
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 23:03