Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 16, 2009, 06:49 AM   #1
Fiddlestick
macrumors newbie
 
Join Date: Jul 2009
When do I use multiple nib files?

I'm quite new to ObjC and Cocoa, but I have good general programming experience in PHP and Java.

I've done some GUI programming in Java using Swing and AWT and I'm finding Interface Builder extremely refreshing and simple to use, but I'm not quite clear when I should be using multiple nib files.

To give an example, I play a popular mmorpg and it provides an API so that players can build tools to download account and character information, so I'm building myself a little tool as it would be a useful thing to have and it would help expand my Cocoa/ObjC knowledge.

A typical use case would be going to a menu from the menubar and clicking an option to add a character. At this point a window would pop up with the character manager, and you would click buttons that would make other dialogue boxes pop up so you can enter your API details and what not.

In Swing I would just generate a new window for this and my listener would read in the details and pass them back to the main execution loop, but I'm not quite sure how I would go about this in Cocoa.

Would I have separate windows that are hidden by default and only appear when you want them to become visible, or would I instead store the windows in seperate nib files, load them on demand and then have them grab focus so that you can't return to the main window until you dismiss the new window?

I hope what I'm trying to do makes sense. I'm enjoying myself so far, but this is part of the Cocoa methodology that I don't quite "get" yet.
Fiddlestick is offline   0 Reply With Quote
Old Jul 16, 2009, 07:12 AM   #2
GorillaPaws
macrumors 6502a
 
GorillaPaws's Avatar
 
Join Date: Oct 2003
Location: Richmond, VA
Quote:
Originally Posted by Fiddlestick View Post
...or would I instead store the windows in seperate nib files, load them on demand and then have them grab focus so that you can't return to the main window until you dismiss the new window?
This is how it's normally done, although I'm not sure if you need to make your window modal (locking focus until completed). You might want to look into the responder chain, the first responder and nil-targeted actions, to get a sense of how focus shifts around. Typically, you should avoid modal windows unless it's absolutely necessary.
GorillaPaws is offline   0 Reply With Quote
Old Jul 16, 2009, 07:27 AM   #3
Fiddlestick
Thread Starter
macrumors newbie
 
Join Date: Jul 2009
Thanks, that's what I suspected.

I take it when I wanted to use it I would instantiate a reference to the nib and then issue some sort of awakeFromNib message to and then make my windows visible?
Fiddlestick is offline   0 Reply With Quote
Old Jul 16, 2009, 08:37 AM   #4
GorillaPaws
macrumors 6502a
 
GorillaPaws's Avatar
 
Join Date: Oct 2003
Location: Richmond, VA
Quote:
Originally Posted by Fiddlestick View Post
Thanks, that's what I suspected.

I take it when I wanted to use it I would instantiate a reference to the nib and then issue some sort of awakeFromNib message to and then make my windows visible?
You're going to want an NSWindowController object to manage that window and it's contents. Also, you might want to consider using an NSPanel for what you're trying to do (panels are just special windows so they still have NSWindowControllers).
GorillaPaws is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
copy multiple file names > then paste to multiple different files maxslomoff Mac Programming 5 Jul 27, 2014 09:52 AM
How can I open multiple files within multiple folders in an app at once? EyeAmLuv OS X Mavericks (10.9) 6 Apr 4, 2014 09:35 PM
Search Multiple Files??? eclipse525 OS X 0 Oct 3, 2012 02:23 PM
Is there a good program to package a group of files into multiple rar files? east85 Mac Applications and Mac App Store 5 Aug 27, 2012 03:00 PM

Forum Jump

All times are GMT -5. The time now is 03:57 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC