


Open Main.storyboard, and go the the View Controller Scene. Make it a subclass of NSView, and make sure that the language is Swift.Ĭlick Next and Create to save your new file. Choose File \ New \ File… and select the macOS \ Source \ Cocoa Class file template.Ĭlick Next, and in the ensuing screen, name the new class GraphView. Select the Views group in the Project Navigator.
What is core app for mac how to#
Follow the next steps to learn how to get there. Override draw(_:) and add some drawing code.You need to accomplish two objectives to create a custom view: It’s where you’ll draw the pie and bar charts, so it’s pretty important. Your first to-do is to create a custom view named GraphView. Note: The app shows the correct disk usage information, but for the sake this tutorial, it creates a random file distribution.Ĭalculating the real file distribution each time you run the app will quickly become a time drain and spoil all your fun, and nobody wants that. MountedVolumesDataSource.swift and MountedVolumesDelegate.swift: Implement the required methods to show disk information in the outline view.CGFloat+Radians.swift: Extension that converts between degrees and radians via some helper functions.NSColor+DiskInfo.swift and NSFont+DiskInfo.swift: Extensions that define constants with the default colors and fonts.VolumeInfo.swift: Contains the implementation of the VolumeInfo class, which reads the information from the hard drive, and the FilesDistribution struct that handles the split between file types.ViewController.swift: The main view controller of the application.The app lists all your hard drives, and when you click on one it shows detailed information.īefore going any further, have a look at the structure of the project to become familiar with the lay of the land: Getting Startedįirst, download the starter project for DiskInfo here.


So put on your painter’s hat and get ready to learn how to color your world. In the first part of this Core Graphics on macOS tutorial, you’ll implement the bar chart using Core Graphics, before moving on to learn how to draw the pie chart using Cocoa Drawing. Use Cocoa Drawing, a tool available to AppKit apps, which defines higher level classes and functions.
What is core app for mac code#
What is core app for mac update#
Update 9/22/16: This tutorial has been updated for Xcode 8 and Swift 3.
