Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
664 views
in Technique[技术] by (71.8m points)

ios7 - How containerURLForSecurityApplicationGroupIdentifier in NSFileManager works on iOS 7

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

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).

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.

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.

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);

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

It would be really great to have this function working.

Regards,

DAB

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

enter image description here

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...