This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func audioBufferListWithObjectID(objectID: AudioObjectID, scope: AudioObjectPropertyScope) throws -> AudioBufferList { | |
var address = audioBufferListAddressWithScope(scope) | |
var length = try propertyDataSizeWithObjectID(objectID, address: address) | |
let bytes = UnsafeMutablePointer<AudioBufferList>.alloc(Int(length)) | |
defer { bytes.destroy() } | |
let status = AudioObjectGetPropertyData(objectID, &address, 0, nil, &length, bytes) | |
if status != noErr { | |
throw TelephoneError.SystemAudioDevicePropertyDataGetError(systemErrorCode: Int(status)) | |
} | |
return bytes.memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserAgent { | |
let observer: UserAgentObserver | |
init(observer: UserAgentObserver) { | |
self.observer = observer | |
} | |
func start() { | |
observer.userAgentDidFinishStarting(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserAgent { | |
let observer: UserAgentObserver | |
init(observer: UserAgentObserver) { | |
self.observer = observer | |
} | |
func start() { | |
observer.userAgentDidFinishStarting(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol PhoneCallRegistry { | |
func callWithIdentifier(identifier: Int) -> PhoneCall? | |
} | |
func hangUpCallWithIdentifier(identifier: Int) { | |
if let call = phoneCallRegistry.callWithIdentifier(identifier) { | |
call.hangUp() | |
} else { | |
print("Could not hang up call") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol PhoneCallRegistry { | |
func callWithIdentifier(identifier: Int) -> PhoneCall | |
} | |
func hangUpCallWithIdentifier(identifier: Int) { | |
phoneCallRegistry.callWithIdentifier(identifier).hangUp() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hangUpFirstCallOnAccountWithIdentifier(identifier: Int) { | |
if let account = accountRegistry.accountWithIdentifier(identifier) { | |
if let call = account.firstCall { | |
call.hangUp() | |
} else { | |
print("Could not find first call for an account") | |
} | |
} else { | |
print("Could not find account") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hangUpFirstCallOnAccountWithIdentifier(identifier: Int) { | |
accountRegistry.accountWithIdentifier(identifier).firstCall.hangUp() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhoneCall { | |
static let nullPhoneCall: PhoneCall = NullPhoneCall() | |
let identifier: Int | |
init(identifier: Int) { | |
self.identifier = identifier | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol PhoneCall { | |
var identifier: Int { get } | |
var isNil: Bool { get } | |
func hangUp() | |
} | |
class RealPhoneCall: PhoneCall { | |
let identifier: Int | |
let isNil = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hangUpFirstCallOnAccountWithIdentifier(identifier: Int) { | |
guard let account = accountRegistry.accountWithIdentifier(identifier) else { | |
print("Could not find account") | |
return | |
} | |
guard let call = account.firstCall else { | |
print("Could not find first call for an account") | |
return | |
} | |
call.hangUp() |
OlderNewer