这段代码确实可以在 iPhone 模拟器上运行,但不能在设备上运行,尽管我正在寻找已写入磁盘文档目录中的文件
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filepath = [documentsDirectory stringByAppendingString:@"notificationScheduled.plist"];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filepath];
if (fileExists) {
NSMutableArray *array = [NSMutableArray arrayWithContentsOfFile:filepath];
NSLog(@"%@", array);
[array addObject:date];
[array writeToFile:filepath atomically:YES];
} else {
NSMutableArray *array = [NSMutableArray arrayWithObject:date];
[array writeToFile:filepath atomically:YES];
}