If I can save data in other class, such as my view controller?
Here is my code
#import "MyviewController.h"
NSString *docPath(){...};
...
@implementation MyViewController
-(void)viewDidLoad{
NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
if(plist){
todoItems = [plist mutableCopy];
}else{
todoItems = [[NSMutableArray alloc] init];
}
//here I want to save data in this controller, which is turned out to be wrong.
- (void)applicationDidEnterBackground:(UIApplication *)application{
[todoItems writeToFile:docPath() atomically:YES];
}
So, How to save data in other class not in Appdelegate?