使用 Google Nearby Messages 时出现“NSConcreteMutableAttributedString initWithString:: nil value" [英] 'NSConcreteMutableAttributedString initWithString:: nil value' when using Google Nearby Messages
问题描述
我正在关注 Google 的使用 NearbyMessages API 的文档.我正在使用 Swift3.我有以下代码来设置应用程序以发布到附近.
I was following Google's documentation for using NearbyMessages API. I'm using Swift3. I have the following code to set up the app to publish to nearby.
let messageManager = GNSMessageManager(apiKey: "someky")
var publication: GNSPublication?
let message = GNSMessage(content:"name".data(using: .utf8))
if let messageManager = messageManager, let message = message {
publication = messageManager.publication(with:message)
}
我在模拟器上运行了该应用程序.然后应用程序在第 5 行(if-let 块中的行)崩溃.这是堆栈跟踪的一部分:
I ran the app on the simulator. Then the app crashes in the 5th line (The line in the if-let block). Here's part of the stack trace:
(
0 CoreFoundation 0x000000011302334b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011271e21e objc_exception_throw + 48
2 CoreFoundation 0x000000011308c265 +[NSException raise:format:] + 197
3 Foundation 0x0000000112229fdc -[NSConcreteMutableAttributedString initWithString:] + 129
4 ProjectLibs 0x000000011879b55a gns_localizedAllowAppToConnectAttributedString + 415
5 ProjectLibs 0x000000011879b8b9 gns_localizedAllowAppToConnectString + 75
6 ProjectLibs 0x000000011879ae9f gcp_verifyDealloc + 24324
)
由于 messageManager 和消息都受到 if-let 块的保护,所以我找不到 nil 异常来自哪里.有谁知道为什么这段代码中会有一个 nil 值?
Since the messageManager and the message are both protected by the if-let block, I cannot find where is the nil exception coming from. Does anyone know why would there be a nil value in this block of code?
非常感谢!
推荐答案
它是否适用于设备?Nearby Messages 1.1.0 中存在一个错误,当您使用 BLE 作为发现媒介时,该错误会导致模拟器上出现 nil 指针异常.
Does it work on a device? There is a bug in Nearby Messages 1.1.0 that causes a nil pointer exception on the simulator when you use BLE as a discovery medium.
抱歉!我们将在下一个版本中修复该错误.
Apologies! We'll get the bug fixed in the next release.
这篇关于使用 Google Nearby Messages 时出现“NSConcreteMutableAttributedString initWithString:: nil value"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!