View Full Version : Help with IB document-based app issue please

Jun 13, 2008, 05:36 PM
Aloha everyone,

I am attempting to create a document-based Cocoa app, but am having a major issue with Interface Builder. Once I get the code entered and double-click on MainMenu.xib, all of the IB elements appear on screen with the notable exception of the main window. I therefore can not drop any UI elements on it, such as text fields, buttons, table views, etc... If I Build and Go, however, the window gets called up like normal, except that there are no UI elements on it (because it doesn't appear when IB is invoked).

I do not have this problem with a "regular" Cocoa app, only with the document-based app. Does anyone know where I can look to find a solution to this rather vexing issue? I'm working my way through Aaron Hillegass' Cocoa Programming for Mac OS X (this is actually my first foray into Mac programming), and can not create the RaiseMan app due to this issue. I've been trying to find a solution to this issue for the past several days and have exhausted all other sources of information. I, therefore, humbly approach everyone here to request assistance. Any and all assistance is greatly appreciated.

Mahalo in advance,


Jun 13, 2008, 06:19 PM
Document-based applications have two nibs by default: MainMenu.nib, and one for the document window, MyDocument.nib. Open MyDocument.nib (or .xib) and you should see the document window object.

(At least that's the way it is in Tiger)

Jun 13, 2008, 07:11 PM
Aloha HiRez,

Thanks for your reply. I'll check that out as soon as I get home from work.


Jun 14, 2008, 02:56 AM
Aloha HiRez,

I just got home from work, after seeing a couple of movies, and finally noticed the MyDocument.xib file. I double-clicked on that, and the missing document window appeared on screen. Thanks for opening my eyes - I am still very much a noob when it comes to Objective-C and Xcode. Thanks ever so much for pointing me in the right direction.


Oct 7, 2008, 02:59 PM
Hi guys,

I am also new to Objective-C. I have a different issue with the RaiseMan app. I have created the document-based app as per instruction from the book.

But when I try to build and run, the RaiseMap app just sits in the dock. No UI Window appears. I am not sure why this is happening. I have never had any problems with just standard Cocoa Applications.

Any help is much appreciated.


Oct 7, 2008, 07:51 PM
@HawaiiMacAddict , hey glad I could help!

@crapzone, some things to check...

• Open the debugging console in Xcode and see if any errors or messages show up when you run the app (for example, an invalid binding can sometimes cause an app to exit).

• Do you have a MyDocument.xib file in your project?

• Did you try to rename your document class or its .xib file at some point? If you did you have to change the name in several places.

• Open MyDocument.xib. Is there a window in it? Is it connected to File's Owner (your document class) as "window", and is File's Owner connected to it as "delegate"? Both must be connected.

• View MyDocument.m. Is the -windowNibName method present and does it look like this?- (NSString *)windowNibName {
return @"MyDocument";

• Put the line NSLog(@"test"); as the first line in your document's -init method (in MyDocument.m). Does it show up in the debugging console when you run the app? If so, put the line inside -windowControllerDidLoadNib:

• Check your project settings to make sure they're correct for your processor type and target OS:

Oct 7, 2008, 08:16 PM
Thanks HiRez for your prompt reply and your very detailed analysis of the problem.

It's working now. The problem was I removed this piece of code from MyDocument.m :

- (NSString *)windowNibName {
return @"MyDocument";

It as auto generated when I created the project. Somehow I stupidly went and deleted those because I thought they were just dummy methods. :P

Thanks heaps for your help!! Much appreciated! =)


Oct 8, 2008, 04:18 AM
Simple advice for everybody,

never ever delete any code generated by the project wizards in Xcode, unless you are a wizard yourself.

You will see that in some programs released today, developers don't even bother changing the name from MyDocument.h and MyDocument.xib, as it can cause massive problems if they forget to change the references anywhere.

Oct 9, 2008, 07:02 PM
Thanks mate! I'll definitely keep that in mind :>