Reputation: 793
I'm trying to set the thickness of a divider of a NSSplitView to a specified CGFloat value but I get the error: "Cannot assign to the result of this expression error in Swift".
I do it this way and it seems like correct, what do you think is wrong with that?
splitView.dividerThickness
is a CGFloat value as you can see in picture 2.
Upvotes: 0
Views: 1005
Reputation: 539765
The property is read-only:
var dividerThickness: CGFloat { get }
so you cannot assign a new value. The documentation states:
You can subclass
NSSplitView
and override this method to change the thickness of a split view’s dividers.
Upvotes: 2
Reputation: 6612
The error seems to be clear enough to fix it : dividerThickness
requires a Float
and not a CGFloat
.
In order to fix it, you can :
var val : Float = 0.0
spitView.dividerThickness = Float(val)
That's because CGFloat
has different size on 32bit and 64bit machines.
Unfortunately, the cast isn't done automatically. But you might be able to find (or write your own) operator overloading.
Upvotes: 0