I have a NSMutablearray that I want to save to file when the application enters background. I have declared my NSMutablearray in my Viewcontroller.h as an instance variable:
#import <UIKit/UIKit.h>
NSString *docPath();
@interface ViewController : UIViewController<UITableViewDataSource>
{
UITableView *taskTable;
UITextField *taskField;
UIButton *insertButton;
NSMutableArray *tasks;
}
- (void)addTask:(id)sender;
@end
Now I need to access this variable in my AppDelegate like so:
- (void)applicationDidEnterBackground:(UIApplication *)application {
[tasks writetofile:docPath() atomically:YES];
}
I am fairly new to this and self taught. I thought some sort of #import "Viewcontroller.h" in the AppDelegate would help, but not sure how to proceed. Any help appreciated.