• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Starting window instead of a new untitled document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Starting window instead of a new untitled document?


  • Subject: Re: Starting window instead of a new untitled document?
  • From: PGM <email@hidden>
  • Date: Mon, 31 Jul 2006 22:34:09 -0400

I have a document-based Cocoa applcation that doesn't create untitled documents (document windows can only be opened for existing document files -- which are essentially databases -- and can't exist without physical set of files).

So I've overridden newDocument: to create a file and overridden applicationShouldOpenUntitledFile: to return NO so that a new document isn't created when the user starts the application or activates it via its dock icon.

But now I'd like to implement a "getting started" window that prompts the user to create a new file or open an existing one. I want this window to appear ONLY when the application is started without opening an existing document. Searching the archives, the advice has been to create this window in applicationWillFinishLaunching:. But I don't want to see the window every time. I only want it to appear if the application was launched without a document to open.

What's the best way to approach this?

The way I do it (so not necessarily the best way) is as follows:

When a new document is created, loadDataRepresentation:ofType: is called pretty early, so I implement this as follows:

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
dataFromFile = [data retain]; //(NSData *)dataFromFile is an instance variable
return YES;
}


Then in windowControllerDidLoadNib, I do something like this:

if(dataFromFile){
	//do something with the data
	[dataFromFile release]; //if you don't need it anymore
}
else{
	//popUp a dialog to set-up new document (I use a modal here)
}

The good thing is that at this point, the document window is not yet visible, so there is no empty document to distract the user.

Best, Patrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Starting window instead of a new untitled document? (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: window title (newbie question)
  • Next by Date: Re: window title (newbie question)
  • Previous by thread: Re: Starting window instead of a new untitled document?
  • Next by thread: Aussie Mac Developers at WWDC?
  • Index(es):
    • Date
    • Thread