NSFileManager中的containerURLForSecurityApplicationGroupIdentifier如何在iOS 7上运行 [英] How containerURLForSecurityApplicationGroupIdentifier in NSFileManager works on iOS 7

查看:1138
本文介绍了NSFileManager中的containerURLForSecurityApplicationGroupIdentifier如何在iOS 7上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS环境中的多个应用程序之间共享文件。

I want to share file between multiple applications in iOS environment.

我已经使用UIDocumentInteractionController机制来达到目的但我遇到了问题因为应用程序之间交换的高容量数据(2Go左右)。

I'm already using the UIDocumentInteractionController mechanism to achieve the purpose but I'm facing a problem because the hight volume of data to exchange between the application (around 2Go).

我正在使用ZipArchive库收集所有共享文件,但在某些情况下它确实无法创建巨大的zip文件。
我试图发送一个目录而不是文件,但内容没有被复制。

I'm using the ZipArchive library to gather all the shared files, but it does fail in some case to create the huge zip file. I've tried to send a directory instead of the file, but the content is not copied.

当我升级到iOS 7时,我'我试图在NSFileManager中使新的可用containerURLForSecurityApplicationGroupIdentifier方法工作。
我遵循了一些例子,但它们是针对MAC OS X的。

As I'm upgrading to iOS 7, I'm trying to make the new available containerURLForSecurityApplicationGroupIdentifier method in NSFileManager working. I've followed the few example, but they are for the MAC OS X.

将此API用于iOS 7是否是一个苹果错误

Is it an apple mistake to have made this API available for iOS 7 too or which instruction are required to make it working.

以下是申请权利文件内容:

Here is the application entitlements file content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>$(TeamIdentifierPrefix)com.example.AppFileSharing</string>
    </array>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)com.example.AppFileSharing</string>
    </array>
</dict>
</plist>

以下是访问容器的示例代码:

Here is the sample code to access the container:

NSFileManager* fileManager = [NSFileManager defaultManager];
NSURL* containerURL = [fileManager 
containerURLForSecurityApplicationGroupIdentifier:@"com.example.AppFileSharing"];
NSLog(@"%@", containerURL);

当我运行应用程序时,containerURL为空。

When I'm running the app, the containerURL is null.

让这个功能工作真的很棒。

It would be really great to have this function working.

问候,

DAB

推荐答案

您可能尚未为您的应用启用应用组。您必须在Apple开发者网站的会员中心为您的应用程序组创建一个标识符。

You probably have not enabled App Groups for your app. You will have to create a Identifier for your App Group in Member Center on the Apple developer site.

这篇关于NSFileManager中的containerURLForSecurityApplicationGroupIdentifier如何在iOS 7上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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