Great tutorial, thanks for writing it, Ernesto.
To help any readers who may be stuck as a result of running Xcode 8 - Beta 6, I’ve provided a few details on how to get the starter project for this tutorial working, with minimal changes (4, to be precise!).
1. Migrate to Swift 2.3
When using Xcode 8 - Beta 6 and migrating to Swift 2.3, which will take less than a minute to do.
Once done, the only changes made to the project are:
MountedVolumesDataSource.swift:53
self.outlineView.setDataSource(self)
becomes
self.outlineView.dataSource = self
And
MountedVolumesDelegate.swift:41
self.outlineView.setDelegate(self)
becomes
self.outlineView.delegate = self
2. Fix Interface Builder constraint errors
If you follow along, when you add the GraphView to the Main.storyboard file and configure the constraints to pin it on all sides, you’ll get an unsatisfiable constraints error in Interface Builder.
This can be resolved by simply by deleting the constant value (0) the ContainerView.top Equal HorizontalLine.Bottom
constraint, allowing it to use some default value (provided by IB).
Unfortunately, @IBDesignable
does not seem to be working properly in Xcode 8 - Beta 6, but as mentioned in the tutorial, you can simply run the application to see your changes.
3. Replace optional CGContextRef with a non-optional CGContextRef.
When following along and adding the Drawing Extension; simply change the
drawRoundedRect method signature to expect a non-optional CGContextRef parameter.
4. Update the call site to ensure a non-optional CGContextRef is passed
When following along and adding the drawBarGraphInContext method to the Drawing Extension; simply add a guard-let to the top of the method - to ensure that you call the drawRoundedRect method (mentioned above) with a valid CGContextRef instance, like so
func drawBarGraphInContext(context: CGContextRef?) {
guard let context = context else { return }
...
}
With that, the tutorial source will work as expected.
Hope that helps.
– Mike.