将文件传递给另一个Iphone应用程序 [英] passing a file to another Iphone application

查看:99
本文介绍了将文件传递给另一个Iphone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道这样做的任何样本或开源代码?或者是一篇解释如何操作的文章?

Is anyone aware of any sample or open-source code that does this? Or a write-up explaining how to do it?

Apple有很多示例代码可以在其他应用程序中打开网址。但我找不到任何应用程序要求其他应用程序打开存储在手机上的文件的示例。

Apple has quite a bit of sample code that opens web addresses in other apps. But I can't find any examples where the app asks another app to open a file that is stored on the phone.

谢谢。

推荐答案

有两种方法可以做到。

1)如果您可以将文件编码为字符串,您可以通过 NSURL 将其传递给另一个应用程序。接收应用程序ReceivingApp必须实现

1) If you can encode your file as a string, you can pass it to another app via an NSURL. The receiving app, "ReceivingApp" must implement the

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 

在它的应用程序委托中。使用

in it's application delegate. Send your data using the

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"receivingapp://your.data.goes.here"]]];

2)使用粘贴板

我会使用自定义URL方案,因为它1)将为您节省几个步骤; 2)如果接收应用程序出现问题,它不会让操作系统的其余部分访问您的数据。我不确定NSURL的字符限制是什么,但它非常大。

I would use the custom URL scheme since it 1) will save you a few steps and 2) it doesn't give the rest of the OS access to your data should something go amiss with the receiving app. I'm not sure what the character limit on an NSURL is, but it's pretty big.

这篇关于将文件传递给另一个Iphone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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