diff options
Diffstat (limited to 'Classes/TopicsViewController.m')
-rw-r--r-- | Classes/TopicsViewController.m | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Classes/TopicsViewController.m b/Classes/TopicsViewController.m index 3ad8d95..d7ca089 100644 --- a/Classes/TopicsViewController.m +++ b/Classes/TopicsViewController.m @@ -35,6 +35,10 @@ [self.tableView setSeparatorColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0]]; objMan = [[HJObjManager alloc] initWithLoadingBufferSize:6 memCacheSize:20]; + + _today = [[Topic dateToString:[NSDate new]] retain]; + _yesterday = [[Topic dateToString:[NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)-86400]] retain]; + _tomorrow = [[Topic dateToString:[NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)+86400]] retain]; NSString* cacheDirectory = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/imgcache/icons/"] ; HJMOFileCache* fileCache = [[[HJMOFileCache alloc] initWithRootPath:cacheDirectory] autorelease]; @@ -81,6 +85,8 @@ [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; + // convert releasedate to today if its tomorrow, acidcowwwww! + [tableDictionary appendObject:topic forKey:[dateFormatter dateFromString:[dateFormatter stringFromDate:topic.releaseDate]]]; } @@ -177,7 +183,7 @@ - (void) loadSubscribedTopics { //NSLog(@"load subscribed"); [db open]; - FMResultSet *result = [db executeQuery:@"SELECT * FROM subscribedSources WHERE subscribed = ?", [NSNumber numberWithInt:1]]; + FMResultSet *result = [db executeQuery:@"SELECT * FROM sources WHERE subscribed = ?", [NSNumber numberWithInt:1]]; while ([result next]) { Source *source = [[[Source alloc] init] autorelease]; if ([sourcesDictionary objectForKey:[NSNumber numberWithInt:[result intForColumn:@"foreignId"]]] != nil) { @@ -253,18 +259,15 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { //NSLog(@"row title: %@", [tableDictionary keyForIndex:section]); //return [tableDictionary keyForIndex:section]; //how do you convert a key to index from mutabledictionary - NSDate *date = [NSDate new]; + NSString *key = [Topic dateToString:[tableDictionary keyForIndex:section]]; - NSString *today = [Topic dateToString:date]; - NSString *yesterday = [Topic dateToString:[NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)-86400]]; - //NSLog(@"%@ %@ %@ %@", date, key, today, yesterday); - //NSLog(@"%@", [tableDictionary allIndices], [tableDictionary ); - //NSLog(@"%@", [tableDictionary allKeys]); - //[tableDictionary allIndices]; - if ([key compare:today] == 0) + + if ([key compare:_today] == 0) return @"Today"; - else if ([key compare:yesterday] == 0) + else if ([key compare:_yesterday] == 0) return @"Yesterday"; + else if ([key compare:_tomorrow] == 0) + return @"Tomorrow"; else return key; @@ -506,6 +509,9 @@ } - (void)dealloc { + [_today release]; + [_yesterday release]; + [_tomorrow release]; [db release]; [sourcesDictionary release]; [tableDictionary release]; |