A collection of user interface components and drawing routines for building tasteful apps using AppKit.
appkit swift aqua ui mac

Set cellClass class variable before first instance is created

Swift weirdly does not allow you to implement +load or +initialize, so
this is my only choice.

+10 -5
+10 -5
Sources/AquaKit/Controls and Views/AquaSegmentedControl.swift
··· 5 5 import AppKit 6 6 7 7 open class AquaSegmentedControl: NSSegmentedControl { 8 + public override init(frame frameRect: NSRect) { 9 + Self.cellClass = AquaSegmentedCell.self 10 + super.init(frame: frameRect) 11 + } 12 + 13 + required public init?(coder: NSCoder) { 14 + fatalError("init(coder:) has not been implemented") 15 + } 16 + 8 17 var segmentWidth: CGFloat = 40 { 9 18 didSet { 10 19 invalidateIntrinsicContentSize() ··· 15 24 return NSSize(width: segmentWidth * CGFloat(segmentCount), height: 35) 16 25 } 17 26 18 - override open var isFlipped: Bool { false } 19 - override open class var cellClass: AnyClass? { 20 - get { AquaSegmentedCell.self } 21 - set {} 22 - } 27 + override open var isFlipped: Bool { false } 23 28 }