1 MCNearbyServiceBrowser
2 MCSessionDelegate
MCNearbyServiceBrowser主要用于发现附近的设备。
/// 初始化MCNearbyServiceBrowser
public init(peer myPeerID: MCPeerID, serviceType: String)
/// MCNearbyServiceBrowserDelegate代理
weak public var delegate: MCNearbyServiceBrowserDelegate?
/// 当前MCPeerID
public var myPeerID: MCPeerID { get }
/// service类型
public var serviceType: String { get }
/// 开始搜索设备
public func startBrowsingForPeers()
/// 结束搜索设备
public func stopBrowsingForPeers()
/// 邀请设备加入会话
public func invitePeer(peerID: MCPeerID, toSession session: MCSession, withContext context: NSData?, timeout: NSTimeInterval)
// 开启搜索附近设备失败
@available(iOS 7.0, *)
optional public func browser(browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: NSError)
// 发现附近的MCPeerID
@available(iOS 7.0, *)
public func browser(browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?)
// 某个MCPeerID消失了
@available(iOS 7.0, *)
public func browser(browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID)
Swift
Multipeer Connectivity Framework Reference
MCNearbyServiceBrowser Class Reference
MCNearbyServiceBrowserDelegate Protocol Reference
时间 | 描述 |
---|---|
2016-01-22 | 博文完成 |
CSDN:http://blog.csdn.net/y550918116j
GitHub:https://github.com/937447974/Blog