PDA

View Full Version : How to buid a multi-window cocoa project




youngplayer
Jun 25, 2008, 08:49 PM
I'm a beginner of Cocoa. And I've read 'Learning Cocoa with objective-c', which only introduces single window programming. In practice, I need to implement multi-window project, but I haven't found such introduction in the books on hand.
Pls tell me how to do, or what book I should refer. Thanks!



liptonlover
Jun 25, 2008, 09:02 PM
I'm not quite sure what you mean. If you mean something like safari where you can open as many windows as you want, you need to create a document based application. If you just want more windows in your application, then just drag more windows out in IB.

youngplayer
Jun 25, 2008, 09:24 PM
I'm not quite sure what you mean. If you mean something like safari where you can open as many windows as you want, you need to create a document based application. If you just want more windows in your application, then just drag more windows out in IB.

I just want to more windows displayed as they should display, which may NOT display at beginning. For example, develop a main window as a client, which including some operation buttons. And when press one of these buttons, a sub window comes out to deal with input, or something else.

HiRez
Jun 25, 2008, 09:43 PM
Just add additional windows to the main nib, set Hidden, and an action to the button that calls a mehod in your app controller. In that method you unhide the widow and call makeKeyAndOrderFront: on it (you'll need an outlet connected to the window in IB). If you window is complex you might consider putting it in its own nib.

youngplayer
Jun 25, 2008, 10:26 PM
Just add additional windows to the main nib, set Hidden, and an action to the button that calls a mehod in your app controller. In that method you unhide the widow and call makeKeyAndOrderFront: on it (you'll need an outlet connected to the window in IB). If you window is complex you might consider putting it in its own nib.

Thanks! Could you talk more about multi-nib programming? It's better to show me some book or sample code to view.

Darkroom
Jun 25, 2008, 10:42 PM
"Cocoa Programming for Mac OS X (http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214451692&sr=8-1)" 3rd Edition by Aaron Hillegass (which was just released last month) discusses document based cocoa apps with several tutorials/examples... it's a great book.

youngplayer
Jun 26, 2008, 12:33 AM
"Cocoa Programming for Mac OS X (http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214451692&sr=8-1)" 3rd Edition by Aaron Hillegass (which was just released last month) discusses document based cocoa apps with several tutorials/examples... it's a great book.

I've got this book. But I'm not going to develop a ducument based app.

youngplayer
Jun 26, 2008, 01:11 AM
Just add additional windows to the main nib, set Hidden, and an action to the button that calls a mehod in your app controller. In that method you unhide the widow and call makeKeyAndOrderFront: on it (you'll need an outlet connected to the window in IB). If you window is complex you might consider putting it in its own nib.


" unhide the widow and call makeKeyAndOrderFront" DOES work. But it has to be added to the main nib. If I want to display several sub-windows, do I have to add several sub-windows to the main nib? If so, I feel not good...

Can I make a sub-window as a Model, and copy and display it as it should occur? How to do so ?