'NSConcreteMutableAttributedString initWithString:: nil value' when using Google Nearby Messages

一个人想着一个人 提交于 2019-12-13 21:51:28

问题


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

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
)

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?

Thank you very much!


回答1:


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.



来源:https://stackoverflow.com/questions/40274860/nsconcretemutableattributedstring-initwithstring-nil-value-when-using-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!