I am trying to use the Multipeer Connectivity framework but I am getting a crash while trying to instantiate MCNearbyServiceBrowser
with a serviceType
called "stc-classroom-vik".
Here is the code:
private func setUpSession() {
self.session = MCSession(peer: self.peerId);
self.session!.delegate = self;
self.browser = MCNearbyServiceBrowser(peer: self.peerId, serviceType: "stc-classroom-vik");
self.browser!.delegate = self;
self.advertiser = MCNearbyServiceAdvertiser(peer: self.peerId, discoveryInfo: nil, serviceType: "stc-classroom-vik");
self.advertiser!.delegate = self;
}
and this is the crash/error I am getting:
2014-08-15 12:24:42.689 Xavier[614:254319] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid serviceType passed to MCNearbyServiceBrowser'
I would really appreciate any help.
I believe you're only allowed to have one hyphen in your
serviceType
parameter string, and it needs to be 15 characters or fewer. Yours has two hyphens and 17 characters.From the comments for
MCNearbyServiceBrowser()
: