summaryrefslogtreecommitdiffstats
path: root/Classes/Topic.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/Topic.m')
-rw-r--r--Classes/Topic.m30
1 files changed, 11 insertions, 19 deletions
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];
}