Learn how to create a cocoa Mac app in this video.
- [Narrator] Now that we're finished with our .net core Character Command line program, it's time to move into the most Mactacular part of this whole course. This is the part where we're actually going to build a graphical user interface that will run on the Mac operating system. This is going to entail adding a new project to my solution. Before I do that though I'm going to go ahead and close up some of these files cause we're not going to need them anytime soon. And I'll go ahead and roll up my two projects.
So now we're pretty much clutter free. As before when we set up Character Command as an addition to our solution, we're going to go through the same process. All right click on the solution, select add, and then select new project. From here the now familiar selection box comes up and this time we want to go down to where it says Mac and then under that, it says App. And what we're going to build here is a Coco App.
Coco is the name of the framework in the Mac operating system that's responsible for drawing user interface elements like windows, buttons, text areas, things like that. So with Coco App selected I'll click next. As before I need to give this a name. I'll call this CharacterGUI. But I don't really want that to appear in the docs so I'm going to select a different name for the doc and I'll type in Character Generator.
It's possible to choose which Mac operating system you want to target. You'll be targeting some version of macOS at a version or later. So if I select a 10.9 it would work on 10.9 and later. I'm just going to stick with the top default here and go with Sierra 10.12. I'll click next. As before I can see a preview of my project. I'm not going to use version control for this one. So I'll go ahead and click create.
And now we have our new CharacterGUI project in here. As you can see this one has lots of stuff in it. Earlier projects were fairly sparse but this one has a lot of files in it comparatively speaking. We'll go through what these do a little bit later as we work with them. But the first thing we're going to want to do in setting up this new project is add our reference just like we did with Character Command. If I open up References I'm going to see stuff in here and that's normal, that comes with the project type that we selected.
I'm going to right click on References, select edit References, and as before, I'm just going to pick Character Library under the projects tab. Then I'll click okay. You should see Character Library added as a Reference. The last thing that you want to do when you're setting up your project is to change the default program that gets run when you click the play button here at the top or if you go to Run and then Start With or Without Debugging.
What actually gets run since there's multiple things in here that are runnable at this point, we need to change the default. So to do that just click on the one that you want to use as the default. Right click it and select Set as Startup Project. You'll note that it turns bold and the other one went to not bold. So the bold one tells you that that's what's going to run when you click the Run button. So now our project is all set up and ready to go.
- Exploring C# on a Mac
- Creating a reusable code library
- Classes and properties
- Loops, arrays, and lists
- Creating a console app
- Creating a command-line app
- Creating a Mac desktop app
- Creating a UI with view controllers and actions