views:

51

answers:

1

I'm porting an application I developed in Visual Studio 2008 over to Cocoa. I'm currently doing a 'learn-as-you-go' approach to Cocoa, so I can experiment with different ideas and techniques in smaller, simpler projects and eventually combine them into one big application.

My program logic is as follows (in a dumbed-down sense). Items in the list are mandated by my boss.

  1. Application is started 1a. Verify CD program is in drive.
  2. Verify license. If found and is valid, skip to step 7
  3. Display license agreement.
  4. Display serial number prompt.
  5. Verify and save serial number.
  6. Hide all prior windows.
  7. Load main application window
  8. Intercept requests and commands from main application window, including making a duplicate main application window
  9. Exit program when requested by user

What would the best bet be for this type of application? From another question I asked, I found out that I should keep the 'main application' window in a separate XIB file from the rest, because I might need to clone and interact with it.

I know that since Cocoa and Objective-C is based off of C, there is a Main method somewhere. But what would you all suggest as a starting place for an application like this?

+1  A: 

So some of this comes down to organization. Like Julien mentioned, you'll want a YouappnameApplicationDelegate class - in fact, Xcode will create and set this up for you when you create a project.

implement the applicationDidFinishLaunching method (which also should be provided by what Xcode gave you), and implement your logic for steps 1 and 2 there (and steps 7, 8, 9).

Steps 3 thru 5 you'll probably want to implement in another class. RegistrationWindowController, or something like that. You may even want to create this window in another nib file (not inside the MainMenu.nib file that Xcode gives you). In the YouappnameApplicationDelegation's applicationDidFinishLaunching method you'd load this nib (see code sample below). That way your code is well organized - which is what Cocoa really guides you to do.

Ok, so now how to load that new nib file:

myInstanceVariable = [[RegistrationWindowController alloc] initWithWindowNibName: @"MyNibName"];
[myInstanceVariable showWindow: self];

RegistrationWindowController should be a subclass of NSWindowController.

That should take you a pretty long way into your research, hope it does help!

RyanWilcox
Thank you much! Right now I've worked on bits and pieces of each component - displaying an RTF and making it read-only, generating and verifying serial numbers, video playback within a window, etc. Developing and completing each step independently of each other. I was just having issues on how I should cement all of these bits and pieces together. THANK YOU RYAN! :)
Jeffrey Kern