Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HawaiiMacAddict

macrumors 6502a
Original poster
Dec 28, 2006
904
0
On one of my Macs of course
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,

:apple:HawaiiMacAddict
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
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)
 

HawaiiMacAddict

macrumors 6502a
Original poster
Dec 28, 2006
904
0
On one of my Macs of course
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.

HawaiiMacAddict
 

crapzone

macrumors newbie
Oct 7, 2008
3
0
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.

Thanks!
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
@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?
Code:
- (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:
xcode_settings.png
xcode_settings_2.png
 

crapzone

macrumors newbie
Oct 7, 2008
3
0
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! =)

Cheers!
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.