How to show a welcome screen at startup if a document does not open when you open the application?

Xcode has a really nice screen that appears on first launch; it shows your recent projects along with resources for you, but it appears only if you did not have an open document when you started it. I would like to make a similar (albeit less complicated) welcome screen. I already developed it in the .nib file, but I should have known how I encoded it when the user opens the application without first opening the document.

Here is the screen I'm referring to (showing my recent projects):

Xcode start screen

+4
source share
1 answer

I assume that OS X [NSUserDefaults standardUserDefaults] works the same as in iOS, in which case you can do something like:

 if (![[NSUserDefaults standardUserDefaults] objectForKey:@"opened"]) { //load your special view here; no documents have been opened; } else { //open up some previously opened document. } 

When the document opens, you can simply do something like:

 [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"opened"]; //doesn't matter what you set as long as something is set. 

Then, if you ever want to reset it (for example, if all documents are closed), you can simply do:

 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"opened"]; 
0
source

Source: https://habr.com/ru/post/1468860/


All Articles