I'm using an `NSMutableArray` to store data from my `UITableView`, and I'd like to store the data in `NSUserDefaults` on the application `didEnterBackground` as well as `willTerminate`. Here's how I'm doing this so far:

Delegate:

```
- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    EXViewController *main = [[EXViewController alloc] init];
    [[NSUserDefaults standardUserDefaults] setObject:main.data forKey:@"dataKey"];
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

    EXViewController *main = [[EXViewController alloc] init];
    [[NSUserDefaults standardUserDefaults] setObject:main.data forKey:@"dataKey"];
}

```

`main.data` is an `NSMutableArray`.

I forgot how to do this, being the fact that I haven't worked with table views in some time. Any help is appreciated, thanks!

Full delegate code (.h):

```
#import <UIKit/UIKit.h>
@class EXViewController;

@interface EXAppDelegate : UIResponder <UIApplicationDelegate> {

EXViewController *_main;
NSString *title;
}

// Data to be added
@property (nonatomic, retain) NSString *title;

// Default properties
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) EXViewController *viewController;

@end

```

And (.m):

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_main = [[EXViewController alloc] init];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[EXViewController alloc] initWithNibName:@"EXViewController" bundle:nil];

// Create navigation controller
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];

self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}

```