Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)applicationDidEnterBackground:(UIApplication *)application
- {
- NSString *path = [self filePath:@"test.txt"];
- if ([[NSFileManager defaultManager] fileExistsAtPath:path])
- {
- NSLog(@"file exist");
- }
- else
- {
- NSLog(@"create file");
- MyObject *myObj = [[MyObject alloc] init];
- myObj.name = @"peter";
- myObj.age = 18;
- myObj.color = @"blue";
- NSMutableData *data = [[NSMutableData alloc] init];
- NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
- [archiver encodeObject:myObj forKey:@"MY_OBJ"];
- [archiver finishEncoding];
- [data writeToFile:path atomically:YES];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement