userInfoTransfer,payload 太大 [英] userInfoTransfer, payload is too big

查看:35
本文介绍了userInfoTransfer,payload 太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 watchOS 应用向 iOS 应用发送大量数据.数据由手表上生成的内容组成.此数据存储在手表上的 Core Data 中.所以我实际上并没有传输文件,在这种情况下我会使用 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.

根据这个:WCSession - PayloadTooLarge

我目前限制为 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,payload 太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆