ios – Multipeer Connectivity:无效的服务类型

ios – Multipeer Connectivity:无效的服务类型,第1张

概述我正在尝试使用Multipeer Connectivity框架,但在尝试使用serviceType实例化MCNeaarbyServiceBrowser时遇到了崩溃. 以下是代码: private func setUpSession() { self.session = MCSession(peer: self.peerId); self.session!.delegate = se 我正在尝试使用Multipeer Connectivity框架,但在尝试使用serviceType实例化MCNeaarbyServicebrowser时遇到了崩溃.

以下是代码:

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;}

这是我得到的崩溃/错误:

2014-08-15 12:24:42.689 XavIEr[614:254319] *** Terminating app due to uncaught exception     'NSinvalidargumentexception',reason: 'InvalID serviceType passed to MCNearbyServicebrowser'

我真的很感激任何帮助.

解决方法 我相信你只允许在你的serviceType参数字符串中使用一个连字符,并且它必须是15个字符或更少.你的有两个连字符和17个字符.

从MCNearbyServicebrowser()的注释:

The serviceType parameter is a short text string used to describe the app’s networking protocol. It should be in the same format as a Bonjour service type: up to 15 characters long and valID characters include ASCII lowercase letters,numbers,and the hyphen. A short name that distinguishes itself from unrelated services is recommended; for example,a text chat app made by ABC company Could use the service type “abc-txtchat”.

总结

以上是内存溢出为你收集整理的ios – Multipeer Connectivity:无效服务类型全部内容,希望文章能够帮你解决ios – Multipeer Connectivity:无效的服务类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1108853.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存