userInfoTransfer,有效载荷太大 [英] userInfoTransfer, payload is too big
问题描述
我正在尝试从watchOS应用程序向iOS应用程序发送大量数据.数据由手表上的生成内容组成.此数据存储在手表的核心数据中.因此,我实际上并没有传输文件,在这种情况下,我将使用transferFile
.在这种情况下,我尝试使用transferFile
,但是需要文件URL.由于我实际上并未传输文件,因此我不确定该怎么做.
I'm trying to send a fair bit of data from a watchOS app, to the iOS app. The data is comprised of generated content on the watch. This data is stored in Core Data on the watch. So I'm not actually transferring a file, in which case I'd use transferFile
. I've attempted to use transferFile
in this case, but a file URL is required. Since I'm not actually transferring a file, I'm not sure what to do.
我目前限于65.5kb.我的平均传输要求为0-兆字节.多数可能在0-400kb之间.
I'm currently limited to 65.5kb. My average transfer requirements are from 0 - in the megabytes. Most are probably between 0 - 400kb.
如何传输这些数据?
我想我可以分解吗?但是,这有点荒谬,因为我还需要iOS应用中的代码才能在使用前将其拼凑在一起.
I guess I could break it up? However that would be a bit hackish, as I'd also need code in the iOS app to piece it back together before use.
这是我打给transferUserInfo
的电话:
func sendDictionary(dict: [String: Any]) {
WCSession.default().transferUserInfo(dict)
}
dict
是Core Data查询中的字典对象.
dict
is a dictionary object from a Core Data query.
谢谢.
推荐答案
您是否尝试过将字典以JSON格式保存在磁盘上,然后通过transferfile()作为数据发送并随后清理文件?
Have you tried saving the dictionary as JSON on disc, then sending that as Data with transferfile() and cleaning up the file afterwards?
这篇关于userInfoTransfer,有效载荷太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!