Documentation Archive Developer
Search

MultipeerConnectivity Changes for Swift

MultipeerConnectivity

Declaration
From
class MCAdvertiserAssistant : NSObject {
    init!(serviceType serviceType: String!, discoveryInfo info: [NSObject : AnyObject]!, session session: MCSession!)
    func start()
    func stop()
    weak var delegate: MCAdvertiserAssistantDelegate!
    var session: MCSession! { get }
    var discoveryInfo: [NSObject : AnyObject]! { get }
    var serviceType: String! { get }
}
To
class MCAdvertiserAssistant : NSObject {
    init(serviceType serviceType: String, discoveryInfo info: [String : String]?, session session: MCSession)
    func start()
    func stop()
    weak var delegate: MCAdvertiserAssistantDelegate?
    var session: MCSession { get }
    var discoveryInfo: [String : String]? { get }
    var serviceType: String { get }
}

Declaration
From
weak var delegate: MCAdvertiserAssistantDelegate!
To
weak var delegate: MCAdvertiserAssistantDelegate?

Declaration
From
var discoveryInfo: [NSObject : AnyObject]! { get }
To
var discoveryInfo: [String : String]? { get }

Declaration
From
init!(serviceType serviceType: String!, discoveryInfo info: [NSObject : AnyObject]!, session session: MCSession!)
To
init(serviceType serviceType: String, discoveryInfo info: [String : String]?, session session: MCSession)

Declaration
From
var serviceType: String! { get }
To
var serviceType: String { get }

Declaration
From
var session: MCSession! { get }
To
var session: MCSession { get }

Declaration
From
protocol MCAdvertiserAssistantDelegate : NSObjectProtocol {
    optional func advertiserAssistantWillPresentInvitation(_ advertiserAssistant: MCAdvertiserAssistant!)
    optional func advertiserAssistantDidDismissInvitation(_ advertiserAssistant: MCAdvertiserAssistant!)
}
To
protocol MCAdvertiserAssistantDelegate : NSObjectProtocol {
    optional func advertiserAssistantWillPresentInvitation(_ advertiserAssistant: MCAdvertiserAssistant)
    optional func advertiserAssistantDidDismissInvitation(_ advertiserAssistant: MCAdvertiserAssistant)
}

DeclarationIntroduction
From
optional func advertiserAssistantDidDismissInvitation(_ advertiserAssistant: MCAdvertiserAssistant!)
iOS 8.0
To
optional func advertiserAssistantDidDismissInvitation(_ advertiserAssistant: MCAdvertiserAssistant)
iOS 7.0

DeclarationIntroduction
From
optional func advertiserAssistantWillPresentInvitation(_ advertiserAssistant: MCAdvertiserAssistant!)
iOS 8.0
To
optional func advertiserAssistantWillPresentInvitation(_ advertiserAssistant: MCAdvertiserAssistant)
iOS 7.0

Declaration
From
class MCBrowserViewController : UIViewController, MCNearbyServiceBrowserDelegate, NSObjectProtocol {
    convenience init!(serviceType serviceType: String!, session session: MCSession!)
    init!(browser browser: MCNearbyServiceBrowser!, session session: MCSession!)
    weak var delegate: MCBrowserViewControllerDelegate!
    var browser: MCNearbyServiceBrowser! { get }
    var session: MCSession! { get }
    var minimumNumberOfPeers: Int
    var maximumNumberOfPeers: Int
}
To
class MCBrowserViewController : UIViewController, MCNearbyServiceBrowserDelegate {
    convenience init(serviceType serviceType: String, session session: MCSession)
    init(browser browser: MCNearbyServiceBrowser, session session: MCSession)
    weak var delegate: MCBrowserViewControllerDelegate?
    var browser: MCNearbyServiceBrowser? { get }
    var session: MCSession { get }
    var minimumNumberOfPeers: Int
    var maximumNumberOfPeers: Int
}

Declaration
From
var browser: MCNearbyServiceBrowser! { get }
To
var browser: MCNearbyServiceBrowser? { get }

Declaration
From
weak var delegate: MCBrowserViewControllerDelegate!
To
weak var delegate: MCBrowserViewControllerDelegate?

Declaration
From
init!(browser browser: MCNearbyServiceBrowser!, session session: MCSession!)
To
init(browser browser: MCNearbyServiceBrowser, session session: MCSession)

Declaration
From
convenience init!(serviceType serviceType: String!, session session: MCSession!)
To
convenience init(serviceType serviceType: String, session session: MCSession)

Declaration
From
var session: MCSession! { get }
To
var session: MCSession { get }

Declaration
From
protocol MCBrowserViewControllerDelegate : NSObjectProtocol {
    func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController!)
    func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController!)
    optional func browserViewController(_ browserViewController: MCBrowserViewController!, shouldPresentNearbyPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!) -> Bool
}
To
protocol MCBrowserViewControllerDelegate : NSObjectProtocol {
    func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController)
    func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController)
    optional func browserViewController(_ browserViewController: MCBrowserViewController, shouldPresentNearbyPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?) -> Bool
}

DeclarationIntroduction
From
optional func browserViewController(_ browserViewController: MCBrowserViewController!, shouldPresentNearbyPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!) -> Bool
iOS 8.0
To
optional func browserViewController(_ browserViewController: MCBrowserViewController, shouldPresentNearbyPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?) -> Bool
iOS 7.0

DeclarationIntroduction
From
func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController!)
iOS 8.0
To
func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController)
iOS 7.0

DeclarationIntroduction
From
func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController!)
iOS 8.0
To
func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController)
iOS 7.0

Raw Value Type
From--
ToInt

DeclarationProtocolsRaw Value Type
From
enum MCErrorCode : Int {
    case Unknown
    case NotConnected
    case InvalidParameter
    case Unsupported
    case TimedOut
    case Cancelled
    case Unavailable
}
Equatable, Hashable, RawRepresentable--
To
enum MCErrorCode : Int {
    case Unknown
    case NotConnected
    case InvalidParameter
    case Unsupported
    case TimedOut
    case Cancelled
    case Unavailable
}
extension MCErrorCode : Hashable, Equatable, __BridgedNSError, ErrorType, RawRepresentable, _ObjectiveCBridgeableErrorType, _BridgedNSError {
}
extension MCErrorCode : Hashable, Equatable, __BridgedNSError, ErrorType, RawRepresentable, _ObjectiveCBridgeableErrorType, _BridgedNSError {
}
Equatable, ErrorType, Hashable, RawRepresentableInt

Declaration
From
class MCNearbyServiceAdvertiser : NSObject {
    init!(peer myPeerID: MCPeerID!, discoveryInfo info: [NSObject : AnyObject]!, serviceType serviceType: String!)
    func startAdvertisingPeer()
    func stopAdvertisingPeer()
    weak var delegate: MCNearbyServiceAdvertiserDelegate!
    var myPeerID: MCPeerID! { get }
    var discoveryInfo: [NSObject : AnyObject]! { get }
    var serviceType: String! { get }
}
To
class MCNearbyServiceAdvertiser : NSObject {
    init(peer myPeerID: MCPeerID, discoveryInfo info: [String : String]?, serviceType serviceType: String)
    func startAdvertisingPeer()
    func stopAdvertisingPeer()
    weak var delegate: MCNearbyServiceAdvertiserDelegate?
    var myPeerID: MCPeerID { get }
    var discoveryInfo: [String : String]? { get }
    var serviceType: String { get }
}

Declaration
From
weak var delegate: MCNearbyServiceAdvertiserDelegate!
To
weak var delegate: MCNearbyServiceAdvertiserDelegate?

Declaration
From
var discoveryInfo: [NSObject : AnyObject]! { get }
To
var discoveryInfo: [String : String]? { get }

Declaration
From
init!(peer myPeerID: MCPeerID!, discoveryInfo info: [NSObject : AnyObject]!, serviceType serviceType: String!)
To
init(peer myPeerID: MCPeerID, discoveryInfo info: [String : String]?, serviceType serviceType: String)

Declaration
From
var myPeerID: MCPeerID! { get }
To
var myPeerID: MCPeerID { get }

Declaration
From
var serviceType: String! { get }
To
var serviceType: String { get }

Declaration
From
protocol MCNearbyServiceAdvertiserDelegate : NSObjectProtocol {
    func advertiser(_ advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler invitationHandler: ((Bool, MCSession!) -> Void)!)
    optional func advertiser(_ advertiser: MCNearbyServiceAdvertiser!, didNotStartAdvertisingPeer error: NSError!)
}
To
protocol MCNearbyServiceAdvertiserDelegate : NSObjectProtocol {
    func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: NSData?, invitationHandler invitationHandler: (Bool, MCSession) -> Void)
    optional func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: NSError)
}

DeclarationIntroduction
From
optional func advertiser(_ advertiser: MCNearbyServiceAdvertiser!, didNotStartAdvertisingPeer error: NSError!)
iOS 8.0
To
optional func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: NSError)
iOS 7.0

DeclarationIntroduction
From
func advertiser(_ advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler invitationHandler: ((Bool, MCSession!) -> Void)!)
iOS 8.0
To
func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: NSData?, invitationHandler invitationHandler: (Bool, MCSession) -> Void)
iOS 7.0

Declaration
From
class MCNearbyServiceBrowser : NSObject {
    init!(peer myPeerID: MCPeerID!, serviceType serviceType: String!)
    func startBrowsingForPeers()
    func stopBrowsingForPeers()
    func invitePeer(_ peerID: MCPeerID!, toSession session: MCSession!, withContext context: NSData!, timeout timeout: NSTimeInterval)
    weak var delegate: MCNearbyServiceBrowserDelegate!
    var myPeerID: MCPeerID! { get }
    var serviceType: String! { get }
}
To
class MCNearbyServiceBrowser : NSObject {
    init(peer myPeerID: MCPeerID, serviceType serviceType: String)
    func startBrowsingForPeers()
    func stopBrowsingForPeers()
    func invitePeer(_ peerID: MCPeerID, toSession session: MCSession, withContext context: NSData?, timeout timeout: NSTimeInterval)
    weak var delegate: MCNearbyServiceBrowserDelegate?
    var myPeerID: MCPeerID { get }
    var serviceType: String { get }
}

Declaration
From
weak var delegate: MCNearbyServiceBrowserDelegate!
To
weak var delegate: MCNearbyServiceBrowserDelegate?

Declaration
From
init!(peer myPeerID: MCPeerID!, serviceType serviceType: String!)
To
init(peer myPeerID: MCPeerID, serviceType serviceType: String)

Declaration
From
func invitePeer(_ peerID: MCPeerID!, toSession session: MCSession!, withContext context: NSData!, timeout timeout: NSTimeInterval)
To
func invitePeer(_ peerID: MCPeerID, toSession session: MCSession, withContext context: NSData?, timeout timeout: NSTimeInterval)

Declaration
From
var myPeerID: MCPeerID! { get }
To
var myPeerID: MCPeerID { get }

Declaration
From
var serviceType: String! { get }
To
var serviceType: String { get }

Declaration
From
protocol MCNearbyServiceBrowserDelegate : NSObjectProtocol {
    func browser(_ browser: MCNearbyServiceBrowser!, foundPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!)
    func browser(_ browser: MCNearbyServiceBrowser!, lostPeer peerID: MCPeerID!)
    optional func browser(_ browser: MCNearbyServiceBrowser!, didNotStartBrowsingForPeers error: NSError!)
}
To
protocol MCNearbyServiceBrowserDelegate : NSObjectProtocol {
    func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?)
    func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID)
    optional func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: NSError)
}

DeclarationIntroduction
From
optional func browser(_ browser: MCNearbyServiceBrowser!, didNotStartBrowsingForPeers error: NSError!)
iOS 8.0
To
optional func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: NSError)
iOS 7.0

DeclarationIntroduction
From
func browser(_ browser: MCNearbyServiceBrowser!, foundPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!)
iOS 8.0
To
func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?)
iOS 7.0

DeclarationIntroduction
From
func browser(_ browser: MCNearbyServiceBrowser!, lostPeer peerID: MCPeerID!)
iOS 8.0
To
func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID)
iOS 7.0

Modified MCPeerID
Declaration
From
class MCPeerID : NSObject, NSCopying, NSSecureCoding, NSCoding {
    init!(displayName myDisplayName: String!)
    var displayName: String! { get }
}
To
class MCPeerID : NSObject, NSCopying, NSSecureCoding, NSCoding {
    init(displayName myDisplayName: String)
    var displayName: String { get }
}

Declaration
From
var displayName: String! { get }
To
var displayName: String { get }

Declaration
From
init!(displayName myDisplayName: String!)
To
init(displayName myDisplayName: String)

Modified MCSession
Declaration
From
class MCSession : NSObject {
    convenience init!(peer myPeerID: MCPeerID!)
    init!(peer myPeerID: MCPeerID!, securityIdentity identity: [AnyObject]!, encryptionPreference encryptionPreference: MCEncryptionPreference)
    func sendData(_ data: NSData!, toPeers peerIDs: [AnyObject]!, withMode mode: MCSessionSendDataMode, error error: NSErrorPointer) -> Bool
    func disconnect()
    func sendResourceAtURL(_ resourceURL: NSURL!, withName resourceName: String!, toPeer peerID: MCPeerID!, withCompletionHandler completionHandler: ((NSError!) -> Void)!) -> NSProgress!
    func startStreamWithName(_ streamName: String!, toPeer peerID: MCPeerID!, error error: NSErrorPointer) -> NSOutputStream!
    weak var delegate: MCSessionDelegate!
    var myPeerID: MCPeerID! { get }
    var securityIdentity: [AnyObject]! { get }
    var encryptionPreference: MCEncryptionPreference { get }
    var connectedPeers: [AnyObject]! { get }
}
extension MCSession {
    func nearbyConnectionDataForPeer(_ peerID: MCPeerID!, withCompletionHandler completionHandler: ((NSData!, NSError!) -> Void)!)
    func connectPeer(_ peerID: MCPeerID!, withNearbyConnectionData data: NSData!)
    func cancelConnectPeer(_ peerID: MCPeerID!)
}
To
class MCSession : NSObject {
    convenience init(peer myPeerID: MCPeerID)
    init(peer myPeerID: MCPeerID, securityIdentity identity: [AnyObject]?, encryptionPreference encryptionPreference: MCEncryptionPreference)
    func sendData(_ data: NSData, toPeers peerIDs: [MCPeerID], withMode mode: MCSessionSendDataMode) throws
    func disconnect()
    func sendResourceAtURL(_ resourceURL: NSURL, withName resourceName: String, toPeer peerID: MCPeerID, withCompletionHandler completionHandler: ((NSError?) -> Void)?) -> NSProgress?
    func startStreamWithName(_ streamName: String, toPeer peerID: MCPeerID) throws -> NSOutputStream
    weak var delegate: MCSessionDelegate?
    var myPeerID: MCPeerID { get }
    var securityIdentity: [AnyObject]? { get }
    var encryptionPreference: MCEncryptionPreference { get }
    var connectedPeers: [MCPeerID] { get }
}
extension MCSession {
    func nearbyConnectionDataForPeer(_ peerID: MCPeerID, withCompletionHandler completionHandler: (NSData, NSError?) -> Void)
    func connectPeer(_ peerID: MCPeerID, withNearbyConnectionData data: NSData)
    func cancelConnectPeer(_ peerID: MCPeerID)
}

Declaration
From
func cancelConnectPeer(_ peerID: MCPeerID!)
To
func cancelConnectPeer(_ peerID: MCPeerID)

Declaration
From
var connectedPeers: [AnyObject]! { get }
To
var connectedPeers: [MCPeerID] { get }

Declaration
From
func connectPeer(_ peerID: MCPeerID!, withNearbyConnectionData data: NSData!)
To
func connectPeer(_ peerID: MCPeerID, withNearbyConnectionData data: NSData)

Declaration
From
weak var delegate: MCSessionDelegate!
To
weak var delegate: MCSessionDelegate?

Declaration
From
convenience init!(peer myPeerID: MCPeerID!)
To
convenience init(peer myPeerID: MCPeerID)

Declaration
From
init!(peer myPeerID: MCPeerID!, securityIdentity identity: [AnyObject]!, encryptionPreference encryptionPreference: MCEncryptionPreference)
To
init(peer myPeerID: MCPeerID, securityIdentity identity: [AnyObject]?, encryptionPreference encryptionPreference: MCEncryptionPreference)

Declaration
From
var myPeerID: MCPeerID! { get }
To
var myPeerID: MCPeerID { get }

Declaration
From
func nearbyConnectionDataForPeer(_ peerID: MCPeerID!, withCompletionHandler completionHandler: ((NSData!, NSError!) -> Void)!)
To
func nearbyConnectionDataForPeer(_ peerID: MCPeerID, withCompletionHandler completionHandler: (NSData, NSError?) -> Void)

Declaration
From
var securityIdentity: [AnyObject]! { get }
To
var securityIdentity: [AnyObject]? { get }

Declaration
From
func sendData(_ data: NSData!, toPeers peerIDs: [AnyObject]!, withMode mode: MCSessionSendDataMode, error error: NSErrorPointer) -> Bool
To
func sendData(_ data: NSData, toPeers peerIDs: [MCPeerID], withMode mode: MCSessionSendDataMode) throws

Declaration
From
func sendResourceAtURL(_ resourceURL: NSURL!, withName resourceName: String!, toPeer peerID: MCPeerID!, withCompletionHandler completionHandler: ((NSError!) -> Void)!) -> NSProgress!
To
func sendResourceAtURL(_ resourceURL: NSURL, withName resourceName: String, toPeer peerID: MCPeerID, withCompletionHandler completionHandler: ((NSError?) -> Void)?) -> NSProgress?

Declaration
From
func startStreamWithName(_ streamName: String!, toPeer peerID: MCPeerID!, error error: NSErrorPointer) -> NSOutputStream!
To
func startStreamWithName(_ streamName: String, toPeer peerID: MCPeerID) throws -> NSOutputStream

Declaration
From
protocol MCSessionDelegate : NSObjectProtocol {
    func session(_ session: MCSession!, peer peerID: MCPeerID!, didChangeState state: MCSessionState)
    func session(_ session: MCSession!, didReceiveData data: NSData!, fromPeer peerID: MCPeerID!)
    func session(_ session: MCSession!, didReceiveStream stream: NSInputStream!, withName streamName: String!, fromPeer peerID: MCPeerID!)
    func session(_ session: MCSession!, didStartReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, withProgress progress: NSProgress!)
    func session(_ session: MCSession!, didFinishReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, atURL localURL: NSURL!, withError error: NSError!)
    optional func session(_ session: MCSession!, didReceiveCertificate certificate: [AnyObject]!, fromPeer peerID: MCPeerID!, certificateHandler certificateHandler: ((Bool) -> Void)!)
}
To
protocol MCSessionDelegate : NSObjectProtocol {
    func session(_ session: MCSession, peer peerID: MCPeerID, didChangeState state: MCSessionState)
    func session(_ session: MCSession, didReceiveData data: NSData, fromPeer peerID: MCPeerID)
    func session(_ session: MCSession, didReceiveStream stream: NSInputStream, withName streamName: String, fromPeer peerID: MCPeerID)
    func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, withProgress progress: NSProgress)
    func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, atURL localURL: NSURL, withError error: NSError?)
    optional func session(_ session: MCSession, didReceiveCertificate certificate: [AnyObject]?, fromPeer peerID: MCPeerID, certificateHandler certificateHandler: (Bool) -> Void)
}

DeclarationIntroduction
From
func session(_ session: MCSession!, didFinishReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, atURL localURL: NSURL!, withError error: NSError!)
iOS 8.0
To
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, atURL localURL: NSURL, withError error: NSError?)
iOS 7.0

DeclarationIntroduction
From
optional func session(_ session: MCSession!, didReceiveCertificate certificate: [AnyObject]!, fromPeer peerID: MCPeerID!, certificateHandler certificateHandler: ((Bool) -> Void)!)
iOS 8.0
To
optional func session(_ session: MCSession, didReceiveCertificate certificate: [AnyObject]?, fromPeer peerID: MCPeerID, certificateHandler certificateHandler: (Bool) -> Void)
iOS 7.0

DeclarationIntroduction
From
func session(_ session: MCSession!, didReceiveData data: NSData!, fromPeer peerID: MCPeerID!)
iOS 8.0
To
func session(_ session: MCSession, didReceiveData data: NSData, fromPeer peerID: MCPeerID)
iOS 7.0

DeclarationIntroduction
From
func session(_ session: MCSession!, didReceiveStream stream: NSInputStream!, withName streamName: String!, fromPeer peerID: MCPeerID!)
iOS 8.0
To
func session(_ session: MCSession, didReceiveStream stream: NSInputStream, withName streamName: String, fromPeer peerID: MCPeerID)
iOS 7.0

DeclarationIntroduction
From
func session(_ session: MCSession!, didStartReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, withProgress progress: NSProgress!)
iOS 8.0
To
func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, withProgress progress: NSProgress)
iOS 7.0

DeclarationIntroduction
From
func session(_ session: MCSession!, peer peerID: MCPeerID!, didChangeState state: MCSessionState)
iOS 8.0
To
func session(_ session: MCSession, peer peerID: MCPeerID, didChangeState state: MCSessionState)
iOS 7.0

Raw Value Type
From--
ToInt

Raw Value Type
From--
ToInt