Search Your Question

What is app group capability in iOS?

Ans : 

If we ever needed to share data between your iOS apps and/or your application targets/extension/widgets , there’s a very easy way to do this using app groups. App group capability introduced with iOS 8.
To do so, we can enable the 'App Group' Capability.
  1. In Xcode’s Project Navigator, Click the 'Project Icon'
You can then use NSUserDefaults initWithSuiteName:.
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.example.app"];
Then set a value in one target…
[sharedDefaults setObject:value forKey:@"key"];
[sharedDefaults synchronize];
And read the associated value in the other target…
NSString *value = [sharedDefaults stringForKey:@"key"];

We can make file observer to be notified for changing value instantly. We can put observer on userdefault.plist file and being notified for some value changed in other application.


Note : BBPortal is example of this.


No comments:

Post a Comment

Thanks