Core Data For Mac Os
In this tutorial, you create a class library that contains a single string-handling method. You implement it as an extension method so that you can call it as if it were a member of the String class.
Get this from a library! Sams teach yourself Core Data for Mac and iOS in 24 hours. 2010 Mac Pro “Six Core”, “Eight Core” and “Twelve Core”.With exception, the following Macs are not supported: 2012 Mac Pro “Quad Core” using the Intel Xeon W3565 Processor; Software. Fusion 12 supports Macs with macOS 11.0 Big Sur and macOS 10.15 Catalina. Fusion 12 does not function on macOS 10.14 and earlier.
A class library defines types and methods that are called by an application. A class library that targets .NET Standard 2.1 can be used by an application that targets any .NET implementation that supports version 2.1 of .NET Standard. When you finish your class library, you can distribute it as a third-party component or as a bundled component with one or more applications.
Note
Your feedback is highly valued. There are two ways you can provide feedback to the development team on Visual Studio for Mac:
- In Visual Studio for Mac, select Help > Report a Problem from the menu or Report a Problem from the Welcome screen, which opens a window for filing a bug report. You can track your feedback in the Developer Community portal.
- To make a suggestion, select Help > Provide a Suggestion from the menu or Provide a Suggestion from the Welcome screen, which takes you to the Visual Studio for Mac Developer Community webpage.
Prerequisites
Install Visual Studio for Mac version 8.6 or later. Select the option to install .NET Core. Installing Xamarin is optional for .NET Core development. For more information, see the following resources:
- Tutorial: Install Visual Studio for Mac.
- Supported macOS versions.
- .NET Core versions supported by Visual Studio for Mac.
Create a solution with a class library project
A Visual Studio solution serves as a container for one or more projects. Create a solution and a class library project in the solution. You'll add additional, related projects to the same solution later.
Start Visual Studio for Mac.
In the start window, select New Project.
In the New Project dialog under the Multi-Platform node, select Library, then select the .NET Standard Library template, and select Next.
In the Configure your new .NET Standard Library dialog, choose '.NET Standard 2.1', and select Next.
Name the project 'StringLibrary' and the solution 'ClassLibraryProjects'. Leave Create a project directory within the solution directory selected. Select Create.
From the main menu, select View > Pads > Solution, and select the dock icon to keep the pad open.
In the Solution pad, expand the
StringLibrary
node to reveal the class file provided by the template, Class1.cs. ctrl-click the file, select Rename from the context menu, and rename the file to StringLibrary.cs. Open the file and replace the contents with the following code:Press ⌘S (command+S) to save the file.
Select Errors in the margin at the bottom of the IDE window to open the Errors panel. Select the Build Output button.
Select Build > Build All from the menu.
The solution builds. The build output panel shows that the build is successful.
Add a console app to the solution
Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character.
In the Solution pad, ctrl-click the
ClassLibraryProjects
solution. Add a new Console Application project by selecting the template from the Web and Console > App templates, and select Next.Select .NET Core 3.1 as the Target Framework and select Next.
Name the project ShowCase. Select Create to create the project in the solution.
Open the Program.cs file. Replace the code with the following code:
The program prompts the user to enter a string. It indicates whether the string starts with an uppercase character. If the user presses the enter key without entering a string, the application ends, and the console window closes.
The code uses the
row
variable to maintain a count of the number of rows of data written to the console window. Whenever it's greater than or equal to 25, the code clears the console window and displays a message to the user.
Add a project reference
Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project.
In the Solutions pad, ctrl-click the Dependencies node of the new ShowCase project. In the context menu, select Add Reference.
In the References dialog, select StringLibrary and select OK.
Run the app
ctrl-click on the ShowCase project and select Run project from the context menu.
Try out the program by entering strings and pressing enter, then press enter to exit.
Additional resources
- .NET Standard versions and the platforms they support.
Core Data Mac Os X Tutorial
Next steps
Core Data For Mac Os Versions
In this tutorial, you created a solution and a library project, and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution.