I'm new to Swift 4, coding in Xcode 9. Trying to create a very simple MacOS drawing app just to learn a bit more about Swift. I copied some very simple tutorial code, but are getting an error "Use of unresolved identifier 'NSRectFill'. I noticed that the compiler hinted that I use __NSRectFill and this worked...but why? Am I doing some wrong?
import Cocoa
class GraphView: NSView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
NSColor.white.setFill()
NSRectFill(bounds)
}
}
Starting in Swift 3, NSRectFill
has been made a method of NSRect / CGRect
. So you should have called bounds.fill()
instead.
Deep down though, it may still relies on some Core Foundation routines like __NSRectFill
. It's better that you avoid those double-underscored functions since they are low-level system stuffs that are poorly documented (at least publicly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With