Associated Object Support for Swift 2.3

This is your AssociatedObjectSupport.swift. It's for Swift 2.3 and it's based on this. It can handles nulls, and non-objects, too (by wrapping them in Lifted).
import UIKit

final class Lifted {
let value: Any
init(_ x: Any) {
value = x
} }
extension NSObject {
func setAssociatedObject(value: T, associativeKey: UnsafePointer<Void>, policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC) {
if let v: AnyObject = value as? AnyObject {
objc_setAssociatedObject(self, associativeKey, v, policy)
}
else {
let liftedObject = Lifted(value)
objc_setAssociatedObject(self, associativeKey, liftedObject, policy)
}
}

func getAssociatedObject(associativeKey: UnsafePointer<Void>) -> T? {
let value = objc_getAssociatedObject(self, associativeKey)
if let value = value as? Lifted {
return value.value as? T
}
return value as? T
} }

Example UIView Extension
And here's an example extension to UIView that uses it. Note the clever use of a private struct to get static variables on the Extension nicely.
extension UIView {    
private struct AssociatedKeys {
static var viewExtension = "viewExtension"
static var anotherView = "someOtherView"
static var someFloat = "someFloat"
}

var someFloat: Float {
get {
return getAssociatedObject(&AssociatedKeys.someFloat) ?? 0.0
}
set {
setAssociatedObject(newValue, associativeKey: &AssociatedKeys.someFloat)
}
}

var baseTransform: CGAffineTransform? {
get {
return getAssociatedObject(&AssociatedKeys.viewExtension)
}
set {
setAssociatedObject(newValue, associativeKey: &AssociatedKeys.viewExtension)
}
}

var anotherView: UIView? {
get {
return getAssociatedObject(&AssociatedKeys.anotherView)
}

set {
setAssociatedObject(newValue, associativeKey: &AssociatedKeys.anotherView)
}
} }


Using the Example
var view = UIView()
view.baseTransform = CGAffineTransformIdentity
print("what's up \(view.baseTransform)")
view.baseTransform = nil
print("what's up \(view.baseTransform == nil)")
view.anotherView = UIView()
print("you got another view? \(view.anotherView) \(view.anotherView?.anotherView)")
view.anotherView = nil
view.someFloat = 32.5
print("what's it? \(view.someFloat)")