From e6eb634beac831e64becc03928a467701f9625cf Mon Sep 17 00:00:00 2001 From: matt handler Date: Wed, 27 Apr 2011 01:25:19 -0400 Subject: made fetcher take a payload, added favicon, turned off statement caching, may turn it back on who knows, added sourceid to topics, added category to topictableviewcell, did a little cleaning --- Classes/Topic.m | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'Classes/Topic.m') diff --git a/Classes/Topic.m b/Classes/Topic.m index 12364f8..36be5f6 100644 --- a/Classes/Topic.m +++ b/Classes/Topic.m @@ -12,7 +12,7 @@ @implementation Topic -@synthesize guid, title, iconUrl, description, releaseDate, category, picCount, foreignId; +@synthesize guid, title, iconUrl, description, releaseDate, category, picCount, foreignId, sourceId; + (Topic *) initFromDatabaseRow:(FMResultSet *)result { NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; @@ -22,6 +22,7 @@ Topic *topic = [[[Topic alloc] init] autorelease]; + topic.sourceId = [NSNumber numberWithInt:[result intForColumn:@"sourceId"]]; topic.guid = [result stringForColumn:@"link"]; topic.title = [result stringForColumn:@"title"]; topic.iconUrl = [result stringForColumn:@"iconUrl"]; @@ -50,6 +51,10 @@ return topic; } +- (Topic *) init { + return self; +} + + (NSString *) getImageUrl:(NSDictionary *)obj { if (obj == nil || [obj class] == [NSNull class]) return nil; else { @@ -66,29 +71,15 @@ return [dateFormatter stringFromDate:date]; } -+ (NSDate *) stringToDate:(NSString *)string { - NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; - [dateFormatter setDateStyle:NSDateFormatterLongStyle]; - [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; - [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; - - return [dateFormatter dateFromString:string]; -} - - (void)serializeToDatabase:(FMDatabase *)db { [db retain]; - NSLog(@"title: %d", [releaseDate timeIntervalSince1970]); + [db executeUpdate:@"INSERT INTO picCasts \ - (foreignId, link, title, description, releaseDate, category, iconUrl, picCount) \ + (foreignId, link, title, description, releaseDate, category, iconUrl, picCount, sourceId) \ VALUES \ - (?, ?, ?, ?, ?, ?, ?, ?)", - foreignId, guid, title, description, releaseDate, category, iconUrl, picCount]; - //NSLog(@"insert id:%d error: %@", [db lastInsertRowId], [db lastErrorMessage]); + (?, ?, ?, ?, ?, ?, ?, ?, ?)", + foreignId, guid, title, description, releaseDate, category, iconUrl, picCount, sourceId]; - // [NSString stringWithFormat:@"number %d", i], - // [NSNumber numberWithInt:i], - // [NSDate date], - // [NSNumber numberWithFloat:2.2f]]; [db release]; } @@ -100,6 +91,7 @@ [releaseDate release]; [category release]; [iconUrl release]; + [sourceId release]; [super dealloc]; } -- cgit v1.2.3