Within a Swift class derived from an Obj-C based framework (but could just as easily be a Swift class with an @objc attribute) I declare two stored properties:
The problem with exposing an Int?
property as NSNumber*
is that you could store a non-Int
-compatible NSNumber
to it from Objective-C.
You can make a computed NSNumber?
property to wrap your Int?
property. The getter would simply return the Int?
variable. The setter would set the Int
variable from -[NSNumber integerValue]
.