There is nothing in the file, but I add row1 to my array right after. NSLog tells me that the array is empty. Why isn't row1 added to the array? All of my other code is fine as far as I can tell. My app worked when I put hard values into the array. Now that I'm loading from a file, it doesn't work.
- (void)viewDidLoad {
//array value
//NSMutableArray *array;
NSString *filePath = [self dataFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
NSMutableArray *array/*array*/ = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
NSDictionary *row1 = [[NSDictionary alloc] initWithObjectsAndKeys:@"Study", @"Task", @"2 hours", @"Length", @"4", @"Hours", @"0", @"Minutes", @"15", @"Tiredness", nil];
[array addObject: row1];
self.tasks = array;
NSLog(@"The contents of the array (file exists) is %@", array);
[array release];
[myTableView reloadData];
}
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:app];
[super viewDidLoad];
}
Please help!
Thanks in advance,
Matt