gpt4 book ai didi

ios - 多点连接 : Invalid service type

转载 作者:IT王子 更新时间:2023-10-29 05:33:43 38 4
gpt4 key购买 nike

我正在尝试使用 Multipeer Connectivity 框架,但在尝试使用名为“stc-classroom-vik”的 serviceType 实例化 MCNearbyServiceBrowser 时发生崩溃。

代码如下:

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 - 多点连接 : Invalid service type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25332934/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com