* refactoring

This commit is contained in:
Adam Nemecek 2018-03-11 23:35:41 -07:00
parent 78529c0526
commit b67ec30eae
7 changed files with 12 additions and 12 deletions

View File

@ -73,7 +73,7 @@ final class LiveViewController: UIViewController {
rtmpStream.attachCamera(DeviceUtil.device(withPosition: currentPosition)) { error in
logger.warn(error.description)
}
rtmpStream.addObserver(self, forKeyPath: "currentFPS", options: NSKeyValueObservingOptions.new, context: nil)
rtmpStream.addObserver(self, forKeyPath: "currentFPS", options: .new, context: nil)
lfView?.attachStream(rtmpStream)
}
@ -125,12 +125,12 @@ final class LiveViewController: UIViewController {
UIApplication.shared.isIdleTimerDisabled = false
rtmpConnection.close()
rtmpConnection.removeEventListener(Event.RTMP_STATUS, selector: #selector(self.rtmpStatusHandler), observer: self)
publish.setTitle("", for: UIControlState())
publish.setTitle("", for: [])
} else {
UIApplication.shared.isIdleTimerDisabled = true
rtmpConnection.addEventListener(Event.RTMP_STATUS, selector: #selector(self.rtmpStatusHandler), observer: self)
rtmpConnection.connect(Preference.defaultInstance.uri!)
publish.setTitle("", for: UIControlState())
publish.setTitle("", for: [])
}
publish.isSelected = !publish.isSelected
}

View File

@ -36,10 +36,10 @@ extension HTTPResponseCompatible {
let bytes: [Data.SubSequence] = newValue.split(separator: HTTPRequest.separator)
for i in 0..<bytes.count {
count += bytes[i].count + 1
guard let line: String = String(bytes: Array(bytes[i]), encoding: String.Encoding.utf8), line != "\r" else {
guard let line: String = String(bytes: Array(bytes[i]), encoding: .utf8), line != "\r" else {
break
}
lines.append(line.trimmingCharacters(in: CharacterSet.newlines))
lines.append(line.trimmingCharacters(in: .newlines))
}
guard let first: [String] = lines.first?.components(separatedBy: " ") else {

View File

@ -333,7 +333,7 @@ final class VideoIOComponent: IOComponent {
defer {
objc_sync_exit(effects)
}
if let _: Int = effects.index(of: effect) {
if let _ = effects.index(of: effect) {
return false
}
effects.append(effect)

View File

@ -113,7 +113,7 @@ public class NetSocket: NSObject {
inputStream.delegate = self
inputStream.schedule(in: runloop!, forMode: .defaultRunLoopMode)
inputStream.setProperty(securityLevel.rawValue, forKey: Stream.PropertyKey.socketSecurityLevelKey)
inputStream.setProperty(securityLevel.rawValue, forKey: .socketSecurityLevelKey)
outputStream.delegate = self
outputStream.schedule(in: runloop!, forMode: .defaultRunLoopMode)

View File

@ -260,7 +260,7 @@ open class RTMPConnection: EventDispatcher {
}
open func connect(_ command: String, arguments: Any?...) {
guard let uri: URL = URL(string: command), let scheme: String = uri.scheme, !connected && RTMPConnection.supportedProtocols.contains(scheme) else {
guard let uri = URL(string: command), let scheme: String = uri.scheme, !connected && RTMPConnection.supportedProtocols.contains(scheme) else {
return
}
self.uri = uri

View File

@ -56,11 +56,11 @@ extension TimerDriver: Running {
final public func startRunning() {
DispatchQueue.global(qos: .userInteractive).async {
if let _: RunLoop = self.runloop {
if let _ = self.runloop {
return
}
self.timer = Timer(
timeInterval: 0.0001, target: self, selector: #selector(TimerDriver.on(timer: )), userInfo: nil, repeats: true
timeInterval: 0.0001, target: self, selector: #selector(on(timer: )), userInfo: nil, repeats: true
)
self.nextFire = mach_absolute_time() + self.interval
self.delegate?.tick(self)

View File

@ -6,9 +6,9 @@ import XCTest
final class EventDispatcherTest: XCTestCase {
func testMain() {
let eventDispatcher: EventDispatcher = EventDispatcher()
eventDispatcher.addEventListener("test", selector: #selector(EventDispatcherTest.onTest(_: )), observer: self)
eventDispatcher.addEventListener("test", selector: #selector(onTest(_: )), observer: self)
eventDispatcher.dispatch("type", bubbles: false, data: "Hoge")
eventDispatcher.removeEventListener("test", selector: #selector(EventDispatcherTest.onTest(_: )), observer: self)
eventDispatcher.removeEventListener("test", selector: #selector(onTest(_: )), observer: self)
eventDispatcher.dispatch("test", bubbles: false, data: "Hoge")
}