0

I try to write to the AppGroup shared container with the following Ojecttive-C code:

NSFileManager *fileManager = [NSFileManager defaultManager]; 
NSURL *path = [fileManager 
   containerURLForSecurityApplicationsGroupIdentifier:@"group.*myGroupIdentifier*"]; 
NSString *vtPath = [path.absoluteString stringByAppendingPathComponent:*fileName*]; 
[fileManager createFileAtPath:vtPath contents:nil attributes:nil]; 
NSFileHandle *vtData = [NSFileHandle fileHandleForWritingPath: vtPath];

At this point vtData is always nil, so I can't write there.

The Path with appended fileName looks like @"file:///Users/***/Library/Developer ... /data/Containers/Shared/AppGroup/ ... /Library/filename.dat"

I have not found a solution after searching for hours. What am I doing wrong?

1
  • Tip: use URLs instead of paths. Commented Aug 8, 2023 at 9:10

1 Answer 1

0

The problem was with the URL I got back: It startet with "file:///".

After converting to a path, it started with "file:/"

After removing the "file:" at the beginning it works now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.