mirror of https://github.com/oxen-io/session-ios
Persist AudioService if CallViewController is dismissed
...in response to CR, move the AudioService off of the CallViewController Adopt multiple observer pattern vs. a singular delegate. Doing so required implementing some machinery to address the ARC (see: Weak.swift) // FREEBIEpull/1/head
parent
3ee94d57d9
commit
87ed662116
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright © 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
/**
|
||||
* Container for a weakly referenced object.
|
||||
*
|
||||
* Only use this for |T| with reference-semantic entities
|
||||
* e.g. inheriting from AnyObject or Class-only protocols, but not structs or enums.
|
||||
*
|
||||
*
|
||||
* Based on https://devforums.apple.com/message/981472#981472, but also supports class-only protocols
|
||||
*/
|
||||
struct Weak<T> {
|
||||
private weak var _value: AnyObject?
|
||||
|
||||
var value: T? {
|
||||
get {
|
||||
return _value as? T
|
||||
}
|
||||
set {
|
||||
_value = newValue as AnyObject
|
||||
}
|
||||
}
|
||||
|
||||
init(value: T) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue