Share NSUserDefaults data between multiple apps

walden systems, objective c, geolocation, ios, CLLocationManager, desiredAccuracy, distanceFilter, startUpdatingLocation, stopUpdatingLocation, delegate, iphone, picture, screen, swipe, iphone, thread, nsthread, uitableviewcell, uitableview, initwithFName, infocellcontroller, nsdate, nsdateformatter nsstring, uuid, time, sleep, uiimage, UIGraphicsBeginImageContext, drawinrect, cgrectmake, nsuserdefaults, standarduserdefaults, setobjectforkey, objectforkey, UIControlEventTouchUpInside, resize picture, merge picture, stringByReplacingOccurrencesOfString, app group
Objective-C defines a small but powerful set of extensions to the ANSI C programming language that enables sophisticated object-oriented programming. Objective-C is the native language for Cocoa programming—it’s the language that the frameworks are written in, and the language that most applications are written in. You can also use some other languages—such as Python and Ruby—to develop programs using the Cocoa frameworks. It’s useful, though, to have at least a basic understanding of Objective-C because Apple’s documentation and code samples are typically written in terms of this language.

In order to have shared defaults between an app and an extension or between 2 apps you have to add an App Group in your settings using the following steps:

     1 - In the Project Navigator click on the *.xcodeproj file (should be at the top).
     2 - To the right of the Project Navigator look for Project and Targets. Under 
         targets click on your primary target (should be the first thing under Targets).
     3 - Towards the top, click on the Capabilities tab.
     4 - In the App Groups section click the switch to the right to turn App Groups ON.
     5 - Click on the + button and add an App Group named someappgroup.com.company.myApp.
     6 - Go to the same place in your other apps and this group should now be available to 
         select. Turn this group on for each app that will be using this shared data.

Note: If you go to the Apple Developer Portal (the Apple website that shows all of your Certificates, Identifiers, Devices and Provisioning Profiles) and go to Identifiers > App Groups you should see this new App Group.

To store data:

1   var userDefaults = NSUserDefaults(suiteName: "someappgroup.com.company.myApp")
2   [[NSUserDefaults userDefaults]
3                      setObject: @"some_value"
4                      forKey:@"some_key"];
5   [[NSUserDefaults userDefaults] synchronize];


To retrieve data:

1    var userDefaults = NSUserDefaults(suiteName: "someappgroup.com.company.myApp")
2    String * some_data
3    some_data = [[NSUserDefaults userDefaults] stringForKey:@"some_key"] ;