private lazy var xpcConnection : NSXPCConnection = {
let aConnection = NSXPCConnection(machServiceName: oppositeInformantBundleID, options: NSXPCConnectionOptions(rawValue: 0))
aConnection.remoteObjectInterface = NSXPCInterface(withProtocol: InformantHelperXPCProtocol.self)
aConnection.interruptionHandler = {
DDLogVerbose("XPC Connection to \(oppositeInformantBundleID) has been interrupted.")
}
aConnection.invalidationHandler = {
DDLogVerbose("XPC Connection to \(oppositeInformantBundleID) has been invalidated.")
}
aConnection.resume()
DDLogVerbose("XPC Connection to \(oppositeInformantBundleID) has been created")
return aConnection
}()Given a lazy instantiation - I need to reset the connection variable in the invalidationHandler. I'm still learning the ins and outs of Swift2, so I'll be frank that I'm a bit hazy here.
What I'd like to happen is that in my invalidationHandler, I can reset xpcConnection back to a lazy nil state so that the next time xpcConnection is called the instantiation code above is run again.