-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rx_NSNetService.swift
43 lines (33 loc) · 1.1 KB
/
Rx_NSNetService.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// Rx_NSNetService.swift
// EdgeRemote
//
// Created by Daniel Poulsen on 10/03/2016.
// Copyright © 2016 cambridgeaudio. All rights reserved.
//
import Foundation
import RxSwift
import RxCocoa
class RxNSNetServiceDelegateProxy : DelegateProxy
, NSNetServiceDelegate
, DelegateProxyType {
class func currentDelegateFor(object: AnyObject) -> AnyObject? {
let service: NSNetService = object as! NSNetService
return service.delegate
}
class func setCurrentDelegate(delegate: AnyObject?, toObject object: AnyObject) {
let service: NSNetService = object as! NSNetService
service.delegate = delegate as? NSNetServiceDelegate
}
}
extension NSNetService{
public var rx_delegate: DelegateProxy {
return proxyForObject(RxNSNetServiceDelegateProxy.self, self)
}
public var rx_netServiceDidResolveAddress: Observable<NSNetService> {
return rx_delegate.observe(#selector(NSNetServiceDelegate.netServiceDidResolveAddress(_:)))
.map { a in
return a[0] as! NSNetService
}
}
}