在应用程序之间命名为UIPasteboard? [英] Named UIPasteboard between apps?
问题描述
是否可以使用命名的UIPasteboard(即不是全局的)在两个应用程序之间传输数据?
Is it possible to use a named UIPasteboard (ie, not the global one) to transfer data between two apps?
- 应用程序
- 我想使用命名的粘贴板,因此用户自己在全局粘贴板中的内容不会被覆盖
- 完全相互独立li>
- the apps are completely independent of each other, so have different bundle IDs from different vendors
- I'd like to use a named pasteboard, so the user's own content in the global pasteboard is not overwritten
Apple的文档说:
Apple's docs say:
粘贴板可能是公共或私人。公共粘贴板称为系统粘贴板;私有粘贴板由应用程序创建,因此称为应用程序粘贴板。
Pasteboards may be public or private. Public pasteboards are called system pasteboards; private pasteboards are created by applications, and hence are called application pasteboards.
这意味着粘贴板可以是全局和公共 或命名和私有。
The implication is that a pasteboard can be either "global and public" or "named and private".
我创建了两个具有不同捆绑ID的应用程序,并且似乎能够使用私有方式将内容从一个应用程序传递到另一个应用程序名为粘贴板。但这只是iOS模拟器的一个功能,还是真正支持但没有很好记录的东西?
I created two apps, with different bundle IDs, and seem to be able to pass stuff from one app to the other using a private named pasteboard. But is that just a feature of the iOS Simulator, or something which really supported but not well documented?
感谢您的见解!
推荐答案
您可以为粘贴板值设置自定义字符串,并在您的应用中使用该字符串,以便您的应用必须使用您的唯一字符串访问该值:
You can set a custom string for your pasteboard value and use that across your apps so your apps have to access the value with your unique string:
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"youruniquestring" create:YES];
[pasteboard setPersistent:YES];
//save the unique identifier string that we created earlier
[pasteboard setString:@"your message"];
这篇关于在应用程序之间命名为UIPasteboard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!