Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mike-ferenduros/11327de14a07a1a595cf662554cc6c62 to your computer and use it in GitHub Desktop.
Save mike-ferenduros/11327de14a07a1a595cf662554cc6c62 to your computer and use it in GitHub Desktop.
Int64 bridging!
extension Int64 : _ObjectiveCBridgeable
{
public init(_ number: NSNumber)
{
self.init(number.longLongValue)
}
public func _bridgeToObjectiveC() -> NSNumber
{
return NSNumber(longLong: self)
}
public static func _getObjectiveCType() -> Any.Type
{
return NSNumber.self
}
public static func _isBridgedToObjectiveC() -> Bool
{
return true
}
public static func _forceBridgeFromObjectiveC(source: NSNumber, inout result: Int64?)
{
result = source.longLongValue
}
public static func _conditionallyBridgeFromObjectiveC(source: NSNumber, inout result: Int64?) -> Bool
{
result = source.longLongValue
return true
}
}
let a = Int64(123)
let b: [AnyObject] = [a] //hurrah!
let c = [a] as NSArray //yay!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment