Hallo liebe Entwicklergemeinde,
ich habe mal wieder ein Problem....
Ich versuche in einer TableView eine IF Schleife unterzubringen. In der Schleife soll abgefragt werden, ob das gespeicherte Datum (CoreData) kleiner ist als das aktuelle. Wenn das gespeicherte Datum kleiner ist, soll die Schrift dieses Inhaltes in der Tabelle rot werden. Wenn nicht, soll es normal bleiben! Soweit so gut. Leider funktioniert es aber nicht. Es wird mal jeder Eintrag in der Tabelle rot, dann mal nur ein oder zwei, mal keiner, usw.... Ich kann leider keine Logik aus dem Verhalten erkennen? Kann mir hier jemand sagen warum das so ist? Mache ich was falsch oder darf ich keine IF Schleife in der configureCell Funktion nutzen?
Hier mein Code:
- (void)configureCell: (UITableViewCell * )cell atIndexPath: (NSIndexPath * )indexPath {
LearningObjects *learningObjects = [fetchedResultsController_ objectAtIndexPath:indexPath];
NSDate *currentDate = [NSDate date];
NSLog(@"currentDate = %@",currentDate);
NSLog(@"remindDate = %@",learningObjects.remindDate);
if (learningObjects.remindDate < currentDate) {
NSLog(@"remindDate < currentDate");
cell.textLabel.textColor = [UIColor redColor];
cell.detailTextLabel.textColor = [UIColor redColor];
cell.textLabel.text = learningObjects.firstLearningObject;
cell.textLabel.font = [UIFont systemFontOfSize:16];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.text = learningObjects.secondLearningObject;
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
cell.detailTextLabel.numberOfLines = 0;
}
else if (learningObjects.remindDate >= currentDate) {
NSLog(@"remindDate >= currentDate");
cell.textLabel.text = learningObjects.firstLearningObject;
cell.textLabel.font = [UIFont systemFontOfSize:16];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.text = learningObjects.secondLearningObject;
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
cell.detailTextLabel.numberOfLines = 0;
cell.textLabel.textColor = [UIColor colorWithHue:(0.60) saturation:0.60 brightness:0.60 alpha:1.0];
cell.detailTextLabel.textColor = [UIColor blackColor];
}
}
ich habe mal wieder ein Problem....
Ich versuche in einer TableView eine IF Schleife unterzubringen. In der Schleife soll abgefragt werden, ob das gespeicherte Datum (CoreData) kleiner ist als das aktuelle. Wenn das gespeicherte Datum kleiner ist, soll die Schrift dieses Inhaltes in der Tabelle rot werden. Wenn nicht, soll es normal bleiben! Soweit so gut. Leider funktioniert es aber nicht. Es wird mal jeder Eintrag in der Tabelle rot, dann mal nur ein oder zwei, mal keiner, usw.... Ich kann leider keine Logik aus dem Verhalten erkennen? Kann mir hier jemand sagen warum das so ist? Mache ich was falsch oder darf ich keine IF Schleife in der configureCell Funktion nutzen?
Hier mein Code:
- (void)configureCell: (UITableViewCell * )cell atIndexPath: (NSIndexPath * )indexPath {
LearningObjects *learningObjects = [fetchedResultsController_ objectAtIndexPath:indexPath];
NSDate *currentDate = [NSDate date];
NSLog(@"currentDate = %@",currentDate);
NSLog(@"remindDate = %@",learningObjects.remindDate);
if (learningObjects.remindDate < currentDate) {
NSLog(@"remindDate < currentDate");
cell.textLabel.textColor = [UIColor redColor];
cell.detailTextLabel.textColor = [UIColor redColor];
cell.textLabel.text = learningObjects.firstLearningObject;
cell.textLabel.font = [UIFont systemFontOfSize:16];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.text = learningObjects.secondLearningObject;
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
cell.detailTextLabel.numberOfLines = 0;
}
else if (learningObjects.remindDate >= currentDate) {
NSLog(@"remindDate >= currentDate");
cell.textLabel.text = learningObjects.firstLearningObject;
cell.textLabel.font = [UIFont systemFontOfSize:16];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.text = learningObjects.secondLearningObject;
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
cell.detailTextLabel.numberOfLines = 0;
cell.textLabel.textColor = [UIColor colorWithHue:(0.60) saturation:0.60 brightness:0.60 alpha:1.0];
cell.detailTextLabel.textColor = [UIColor blackColor];
}
}