0

I have two apps, (AppA and AppB). I want to save data in AppA and access it in AppB using App Group:

Code in App A:

- (IBAction)btnSetValuePressed:(id)sender {

    NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.tcompany.testName"];

    [myDefaults setObject:@"foo" forKey:@"bar"];
    [myDefaults synchronize];
}

Code in App B:

NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.tcompany.testName"];
NSString *myString = [myDefaults objectForKey:@"bar"];
self.lblResult.text = myString;

Problem:

Is It secured enough?

user1872384
  • 6,886
  • 11
  • 61
  • 103

1 Answers1

0

It is secure in the sense that only the apps with access to that app group can see that data.

Each app has a sandbox and only that app may access its content. Let's call these apps, "app A" and "app B", there are therefore two sandboxes, sandboxA and sandboxB

When you define an app group you effectively create a third sandbox that is shared between your apps, let's call it sandboxC

Only those two apps can see that shared data, so in this expanded sense both apps as a pair have a secure private area for data.

App A can see sandboxA but not sandboxB App B can see sandboxB but not sandboxA Both app A and B can read and write to SandboxC

Note that both apps run in different processes so it could be possible for App A to be writing data to sandbox C at the same time that app B is reading from the same stored data item, for this reason care must be exercised to avoid possible conflicts.

If you use NSUserDefaults as the storage medium you are going to be safe because Apple ensure that NSUserDefaults behaves correctly in these concurrent circumstances.

Rocket Garden
  • 1,166
  • 11
  • 26