I'm trying to rewrite the following code from the Status Bar Programming Topics in Swift.
NSStatusBar *bar = [NSStatusBar systemStatusBar];
theItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[theItem retain];
[theItem setTitle: NSLocalizedString(@"Tablet",@"")];
...
My Swift code so far:
let bar = NSStatusBar.systemStatusBar()
let sm = bar.statusItemWithLength(NSVariableStatusItemLength)
sm.title = "Tablet"
...
The problem is that the statusItemWithLength
method in Swift excepts CGFloat
but NSVariableStatusItemLength
is defined as CInt
in Swift. I see the following error:
'CInt' is not convertible to 'CGFloat'
Definition in Xcode:
var NSVariableStatusItemLength: CInt { get }
var NSSquareStatusItemLength: CInt { get }
class NSStatusBar : NSObject {
class func systemStatusBar() -> NSStatusBar!
func statusItemWithLength(length: CGFloat) -> NSStatusItem!
...
}
Am I doing something wrong? How can I fix this?