From 8d22d9f522adc00cde8a5f0f703480261a323aeb Mon Sep 17 00:00:00 2001 From: Jon Sterling Date: Mon, 16 Feb 2026 01:00:09 +0000 Subject: [PATCH] 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. --- .../Controls and Views/AquaSegmentedControl.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sources/AquaKit/Controls and Views/AquaSegmentedControl.swift b/Sources/AquaKit/Controls and Views/AquaSegmentedControl.swift index c4c0fa7..37cca45 100644 --- a/Sources/AquaKit/Controls and Views/AquaSegmentedControl.swift +++ b/Sources/AquaKit/Controls and Views/AquaSegmentedControl.swift @@ -5,6 +5,15 @@ import AppKit open class AquaSegmentedControl: NSSegmentedControl { + public override init(frame frameRect: NSRect) { + Self.cellClass = AquaSegmentedCell.self + super.init(frame: frameRect) + } + + required public init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + var segmentWidth: CGFloat = 40 { didSet { invalidateIntrinsicContentSize() @@ -15,9 +24,5 @@ open class AquaSegmentedControl: NSSegmentedControl { return NSSize(width: segmentWidth * CGFloat(segmentCount), height: 35) } - override open var isFlipped: Bool { false } - override open class var cellClass: AnyClass? { - get { AquaSegmentedCell.self } - set {} - } + override open var isFlipped: Bool { false } } -- 2.51.2