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/Fetcher.h | 10 ++- Classes/Fetcher.m | 17 +++- Classes/Source.h | 2 + Classes/Source.m | 11 +-- Classes/SourcesEditViewController.m | 12 +-- Classes/Topic.h | 4 +- Classes/Topic.m | 30 +++---- Classes/TopicTableViewCell.h | 2 + Classes/TopicTableViewCell.m | 2 +- Classes/TopicTableViewCell.xib | 89 ++++++++++++------ Classes/TopicsViewController.h | 16 ++-- Classes/TopicsViewController.m | 175 ++++++++++++++++++++---------------- 12 files changed, 221 insertions(+), 149 deletions(-) (limited to 'Classes') diff --git a/Classes/Fetcher.h b/Classes/Fetcher.h index d51a39d..cc32aba 100644 --- a/Classes/Fetcher.h +++ b/Classes/Fetcher.h @@ -13,17 +13,25 @@ - (void) connection:(NSURLConnection *)connection failedWithError:(NSError *)error; - (void) connection:(NSURLConnection *)connection finishedWithData:(NSData *)data; +@optional + +- (void) connection:(NSURLConnection *)connection failedWithError:(NSError *)error andPayload:(id)payload; +- (void) connection:(NSURLConnection *)connection finishedWithData:(NSData *)data andPayload:(id)payload; + @end @interface Fetcher : NSObject { NSMutableData *receivedData; id delegate; + id payload; } @property (nonatomic, assign) id delegate; +@property (nonatomic, retain) id payload; -+ (Fetcher *) initWithString:(NSString *)string andDelegate:(id )delegate; ++ (Fetcher *) initWithString:(NSString *)string payload:(id)p andDelegate:(id )d; ++ (Fetcher *) initWithString:(NSString *)string andDelegate:(id )d; - (void) setUrlAndConnect:(NSString *)string; @end diff --git a/Classes/Fetcher.m b/Classes/Fetcher.m index 3fe162f..6e3e7b3 100644 --- a/Classes/Fetcher.m +++ b/Classes/Fetcher.m @@ -11,11 +11,16 @@ @implementation Fetcher -@synthesize delegate; +@synthesize delegate, payload; + (Fetcher *) initWithString:(NSString *)string andDelegate:(id)d { + return [Fetcher initWithString:string payload:nil andDelegate:d]; +} + ++ (Fetcher *) initWithString:(NSString *)string payload:(id)p andDelegate:(id )d { Fetcher *fetcher = [[[Fetcher alloc] init] autorelease]; fetcher.delegate = d; + if (payload != nil) fetcher.payload = p; [fetcher setUrlAndConnect:string]; return fetcher; } @@ -46,11 +51,17 @@ } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - [delegate connection:connection failedWithError:error]; + if (payload != nil && [(NSObject *)delegate respondsToSelector:@selector(connection:failedWithError:andPayload:)]) + [delegate connection:connection failedWithError:error andPayload:payload]; + else + [delegate connection:connection failedWithError:error]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { - [delegate connection:connection finishedWithData:receivedData]; + if (payload != nil && [(NSObject *)delegate respondsToSelector:@selector(connection:finishedWithData:andPayload:)]) + [delegate connection:connection finishedWithData:receivedData andPayload:payload]; + else + [delegate connection:connection finishedWithData:receivedData]; } - (void) dealloc { diff --git a/Classes/Source.h b/Classes/Source.h index ea8fe0d..1793d4b 100644 --- a/Classes/Source.h +++ b/Classes/Source.h @@ -15,8 +15,10 @@ NSString *category; BOOL subscribed; NSNumber *foreignId; + NSString *favicon; } +@property (retain) NSString *favicon; @property (retain) NSString *category; @property (retain) NSString *title; @property BOOL subscribed; diff --git a/Classes/Source.m b/Classes/Source.m index f36e41e..bde21b0 100644 --- a/Classes/Source.m +++ b/Classes/Source.m @@ -12,7 +12,7 @@ @implementation Source -@synthesize title, foreignId, subscribed, category; +@synthesize title, foreignId, subscribed, category, favicon; //+ (Topic *) initFromDatabaseRow:(FMResultSet *)result { // NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; @@ -41,6 +41,7 @@ source.foreignId = [NSNumber numberWithInt:[result intForColumn:@"foreignId"]]; source.subscribed = [result intForColumn:@"subscribed"] == 0 ? false : true; source.category = [result stringForColumn:@"category"]; + source.favicon = [result stringForColumn:@"favicon"]; return source; } @@ -50,7 +51,7 @@ Source *source = [[[Source alloc] init] autorelease]; //NSDictionary *info = [obj objectForKey:@"fields"]; - + source.favicon = [NSString stringWithFormat:@"http://www.%@.com/favicon.ico", [obj objectForKey:@"shortname"]]; //[obj objectForKey:@"favicon"]; source.title = [obj objectForKey:@"title"]; source.foreignId = [obj objectForKey:@"id"]; source.subscribed = false; @@ -63,10 +64,10 @@ [db retain]; [db executeUpdate:@"INSERT INTO subscribedSources \ - (foreignId, title, subscribed, category) \ + (foreignId, title, subscribed, category, favicon) \ VALUES \ - (?, ?, ?, ?);", - foreignId, title, [NSNumber numberWithInt:(subscribed ? 1 : 0)], category]; + (?, ?, ?, ?, ?);", + foreignId, title, [NSNumber numberWithInt:(subscribed ? 1 : 0)], category, favicon]; [db release]; } diff --git a/Classes/SourcesEditViewController.m b/Classes/SourcesEditViewController.m index 0d5bd85..7c7bf7b 100644 --- a/Classes/SourcesEditViewController.m +++ b/Classes/SourcesEditViewController.m @@ -52,9 +52,9 @@ sectionDictionary = [[[SectionDictionary alloc] init] retain]; db = [[FMDatabase databaseWithPath:[PicCastAppDelegate getDatabasePath]] retain]; - [db setShouldCacheStatements:YES]; - [db setTraceExecution:true]; - [db setLogsErrors:true]; + [db setShouldCacheStatements:NO]; + //[db setTraceExecution:true]; + //[db setLogsErrors:true]; [self loadSourcesFromDb]; @@ -130,10 +130,10 @@ //NSLog(@"class: %@", [array class]); [db open]; for (NSDictionary *obj in array) { - NSLog(@"foreign key: %d", [obj objectForKey:@"id"]); + //NSLog(@"foreign key: %d", [obj objectForKey:@"id"]); FMResultSet *result = [db executeQuery:@"SELECT * FROM subscribedSources WHERE foreignId = ?", [obj objectForKey:@"id"]]; if (![result next]) { - NSLog(@"found source"); + //NSLog(@"found source"); Source *source = [Source initWithJsonObject:obj]; [sectionDictionary appendObject:source forKey:source.category]; @@ -260,7 +260,7 @@ MyButton *switcher = (MyButton *)sender; NSIndexPath *indexPath = switcher.indexPath; NSNumber *foreignId = [[[sectionDictionary objectForIndex:indexPath.section] objectAtIndex:indexPath.row] foreignId]; - NSLog(@"number %d", foreignId); + NSLog(@"number %@", foreignId); [db open]; [db beginTransaction]; diff --git a/Classes/Topic.h b/Classes/Topic.h index 93c1925..fd01bfb 100644 --- a/Classes/Topic.h +++ b/Classes/Topic.h @@ -19,9 +19,11 @@ NSNumber *picCount; NSString *guid; NSNumber *foreignId; + NSNumber *sourceId; } +@property (nonatomic, retain) NSNumber *sourceId; @property (nonatomic, retain) NSNumber *foreignId; @property (nonatomic, copy) NSNumber *picCount; @property (nonatomic, copy) NSString *title; @@ -34,7 +36,7 @@ + (Topic *) initFromDatabaseRow:(FMResultSet *)result; + (Topic *) initWithJsonObject:(NSDictionary *)obj; + (NSString *) dateToString:(NSDate *)date; -+ (NSDate *) stringToDate:(NSString *)string; - (void) serializeToDatabase:(FMDatabase *)db; + (NSString *) getImageUrl:(NSDictionary *)obj; + @end 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]; } diff --git a/Classes/TopicTableViewCell.h b/Classes/TopicTableViewCell.h index 583d56c..a78b3a5 100644 --- a/Classes/TopicTableViewCell.h +++ b/Classes/TopicTableViewCell.h @@ -16,6 +16,7 @@ BOOL useDarkBackground; IBOutlet UILabel *titleLabel; + IBOutlet UILabel *categoryLabel; IBOutlet UILabel *picCountLabel; IBOutlet UIImageView *icon; IBOutlet UIImageView *gradient; @@ -23,6 +24,7 @@ @property BOOL useDarkBackground; @property (nonatomic, retain) UIImageView *gradient; @property (nonatomic, retain) UILabel *titleLabel; +@property (nonatomic, retain) UILabel *categoryLabel; @property (nonatomic, retain) UIImageView *icon; @property (nonatomic, retain) UILabel *picCountLabel; @property (retain) NSString *picCount; diff --git a/Classes/TopicTableViewCell.m b/Classes/TopicTableViewCell.m index 2e87d28..c2753b6 100644 --- a/Classes/TopicTableViewCell.m +++ b/Classes/TopicTableViewCell.m @@ -11,7 +11,7 @@ @implementation TopicTableViewCell -@synthesize title, iconUrl, picCount, picCountLabel, gradient; // titleLabel, icon +@synthesize title, iconUrl, picCount, picCountLabel, gradient, categoryLabel; // titleLabel, icon - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { diff --git a/Classes/TopicTableViewCell.xib b/Classes/TopicTableViewCell.xib index a66bd79..a62d0cb 100644 --- a/Classes/TopicTableViewCell.xib +++ b/Classes/TopicTableViewCell.xib @@ -47,18 +47,6 @@ 256 YES - - - 292 - {320, 100} - - NO - IBCocoaTouchFramework - - NSImage - gradient.png - - 292 @@ -72,7 +60,7 @@ Title Helvetica-Bold - 22 + 20 16 @@ -158,6 +146,30 @@ YES 2 + + + 292 + {{127, 67}, {43, 27}} + + NO + YES + 7 + NO + IBCocoaTouchFramework + category + + Helvetica-LightOblique + 11 + 16 + + + 3 + MC4zMzMzMzMzMzMzAA + + + 1 + 10 + {300, 100} @@ -205,11 +217,11 @@ - gradient + categoryLabel - + - 19 + 21 @@ -242,7 +254,7 @@ - + @@ -272,8 +284,8 @@ - 18 - + 20 + @@ -288,11 +300,11 @@ 13.IBPluginDependency 13.IBViewBoundsToFrameTransform 16.IBPluginDependency - 18.IBPluginDependency - 18.IBViewBoundsToFrameTransform 2.CustomClassName 2.IBEditorWindowLastContentRect 2.IBPluginDependency + 20.IBPluginDependency + 20.IBViewBoundsToFrameTransform 3.IBPluginDependency 3.IBViewBoundsToFrameTransform 9.IBPluginDependency @@ -306,15 +318,17 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin - P4AAAL+AAABDFAAAwrYAAA + P4AAAL+AAABDiQAAwrgAAA com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - TopicTableViewCell {{460, 755}, {320, 100}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + AUOJAABChgAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin P4AAAL+AAABDJAAAwrAAAA @@ -337,7 +351,7 @@ - 19 + 21 @@ -349,6 +363,7 @@ YES YES + categoryLabel gradient icon picCountLabel @@ -356,6 +371,7 @@ YES + UILabel UIImageView UIImageView UILabel @@ -366,6 +382,7 @@ YES YES + categoryLabel gradient icon picCountLabel @@ -373,6 +390,10 @@ YES + + categoryLabel + UILabel + gradient UIImageView @@ -469,6 +490,20 @@ Foundation.framework/Headers/NSURLConnection.h + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + NSObject @@ -564,10 +599,6 @@ YES ../PicCast.xcodeproj 3 - - gradient.png - {320, 100} - 132 diff --git a/Classes/TopicsViewController.h b/Classes/TopicsViewController.h index 490046d..98a678c 100644 --- a/Classes/TopicsViewController.h +++ b/Classes/TopicsViewController.h @@ -7,7 +7,6 @@ // #import -#import "XMLParser.h" #import "HJObjManager.h" //#import "PicDumpViewController.h" #import "SourcesEditViewController.h" @@ -15,32 +14,31 @@ #import "FMDatabase.h" #import "SectionDictionary.h" #import "Fetcher.h" +#import "Source.h" -@interface TopicsViewController : UIViewController { +@interface TopicsViewController : UIViewController { UINavigationController *topicsNavigationController; - NSMutableArray *topics; // topics loaded from the web + NSMutableDictionary *sourcesDictionary; SectionDictionary *tableDictionary; // structure to sync with table PhotoViewController *photoViewController; - XMLParser *parser; + HJObjManager* objMan; + FMDatabase* db; } - (IBAction)showSources:(id)sender; +@property (nonatomic, retain) NSMutableDictionary *sourcesDictionary; @property (nonatomic, retain) IBOutlet UITableView *tableView; @property (nonatomic, retain, readonly) UINavigationController *topicsNavigationController; @property (nonatomic, retain) PhotoViewController *photoViewController; -@property (nonatomic, retain) NSMutableArray *topics; -//@property (nonatomic, retain, readonly) PicDumpViewController *picDumpViewController; -@property (nonatomic, retain) XMLParser *parser; -// Called by the ParserChoiceViewController based on the selected parser type. -- (void)startParsing; - (void)getTopicsFromDb; - (void)addTopicToSectionDictionary:(Topic *)topic; - (void)loadSubscribedTopics; - (void)addTopicsFromJson:(NSData *)topics; +- (void)addTopicsFromJson:(NSData *)data forSource:(Source *)source; @end diff --git a/Classes/TopicsViewController.m b/Classes/TopicsViewController.m index 3431e62..31191ee 100644 --- a/Classes/TopicsViewController.m +++ b/Classes/TopicsViewController.m @@ -7,7 +7,6 @@ // #import "TopicsViewController.h" -#import "XMLParser.h" #import "Topic.h" #import "TopicTableViewCell.h" #import "AcidCowFeedburnerParser.h" @@ -22,10 +21,11 @@ #import "PicCastAppDelegate.h" #import "CJSONDeserializer.h" #import "Fetcher.h" +#import "Source.h" @implementation TopicsViewController -@synthesize topics, parser, tableView; +@synthesize tableView, sourcesDictionary; - (void)viewDidLoad { [super viewDidLoad]; @@ -44,9 +44,11 @@ [fileCache trimCacheUsingBackgroundThread]; tableDictionary = [[[SectionDictionary alloc] init] retain]; - + sourcesDictionary = [[[NSMutableDictionary alloc] init] retain]; + + db = [[FMDatabase databaseWithPath:[PicCastAppDelegate getDatabasePath]] retain]; - [db setShouldCacheStatements:YES]; + [db setShouldCacheStatements:NO]; // [db setTraceExecution:true]; // [db setLogsErrors:true]; @@ -109,19 +111,21 @@ #pragma mark - #pragma mark custom sheeyit -- (void) addTopicsFromJson:(NSData *)data { - +- (void) addTopicsFromJson:(NSData *)data forSource:(Source *)source { + NSError *theError = nil; id dictionary = [[CJSONDeserializer deserializer] deserialize:(NSData *)data error:&theError]; NSArray *array = [dictionary objectForKey:@"list"]; - + [db open]; for (NSDictionary *obj in array) { - NSLog(@"foreign key: %d", [obj objectForKey:@"id"]); FMResultSet *result = [db executeQuery:@"SELECT id FROM picCasts WHERE foreignId = ?", [obj objectForKey:@"id"]]; if (![result next]) { NSLog(@"found new topic"); Topic *topic = [Topic initWithJsonObject:obj]; + topic.sourceId = source.foreignId; + + if ([topic.picCount intValue] == 0) break; [db beginTransaction]; [topic serializeToDatabase:db]; @@ -133,43 +137,60 @@ } [db close]; - [self.tableView reloadData]; + [self.tableView reloadData]; + } -// called after parsing is finished -- (void) updateTopicsFromWeb:(NSArray *)parsedTopics { - // add topics to sql - [db open]; - for (Topic *topic in parsedTopics) { - // if topic is already in database - //FMResultSet *rs = [db executeQuery:@"SELECT id FROM picCasts WHERE foreignId = ?", [NSNumber numberWithInt:10]]; - if (true) { - //[rs close]; +- (void) addTopicsFromJson:(NSData *)data { + + NSError *theError = nil; + id dictionary = [[CJSONDeserializer deserializer] deserialize:(NSData *)data error:&theError]; + NSArray *array = [dictionary objectForKey:@"list"]; + + [db open]; + for (NSDictionary *obj in array) { + FMResultSet *result = [db executeQuery:@"SELECT id FROM picCasts WHERE foreignId = ?", [obj objectForKey:@"id"]]; + if (![result next]) { + Topic *topic = [Topic initWithJsonObject:obj]; + + if (topic.picCount == 0) break; + [db beginTransaction]; [topic serializeToDatabase:db]; [db commit]; - // add topics to structure [self addTopicToSectionDictionary:topic]; } - } + [result close]; + } [db close]; - // tell table to animate things being added - [self.tableView reloadData]; + [self.tableView reloadData]; } - (void) loadSubscribedTopics { + NSLog(@"load subscribed"); [db open]; - FMResultSet *result = [db executeQuery:@"SELECT foreignId FROM subscribedSources WHERE subscribed = ?", [NSNumber numberWithInt:1]]; + FMResultSet *result = [db executeQuery:@"SELECT * FROM subscribedSources WHERE subscribed = ?", [NSNumber numberWithInt:1]]; while ([result next]) { - + Source *source = [[[Source alloc] init] autorelease]; + if ([sourcesDictionary objectForKey:[NSNumber numberWithInt:[result intForColumn:@"foreignId"]]] != nil) { + source = [sourcesDictionary objectForKey:[NSNumber numberWithInt:[result intForColumn:@"foreignId"]]]; + } + else { + source = [Source initFromDatabaseRow:result]; + [sourcesDictionary setObject:source forKey:source.foreignId]; + } + Fetcher *fetcher = [Fetcher initWithString:[NSString - stringWithFormat:@"http://piccast.memeschemes.com/json/sets_by_feed/%d/", - [result intForColumn:@"foreignId"]] + stringWithFormat:@"http://piccast.memeschemes.com/json/sets_by_feed/%@/", + source.foreignId] + payload:source andDelegate:self]; } + [result close]; + [db close]; } #pragma mark - @@ -184,6 +205,10 @@ [self addTopicsFromJson:data]; } +- (void) connection:(NSURLConnection *)connection finishedWithData:(NSData *)data andPayload:(id)payload { + [self addTopicsFromJson:data forSource:(Source *)payload]; +} + #pragma mark - #pragma mark Table view data source @@ -276,9 +301,11 @@ Topic *topic = [[tableDictionary objectForIndex:[indexPath section]] objectAtIndex:[indexPath row]]; //cell.useDarkBackground = (indexPath.row % 2 == 0); cell.title = topic.title; + [cell.categoryLabel setText:topic.category]; + cell.picCount = [NSString stringWithFormat:@"%@", topic.picCount]; - micon.url = [NSURL URLWithString:@"http://www.acidcow.com/favicon.ico"]; + micon.url = [NSURL URLWithString:[[sourcesDictionary objectForKey:topic.sourceId] favicon]]; mi.url = [NSURL URLWithString:topic.iconUrl]; mi.squareCropped = true; @@ -343,51 +370,51 @@ return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - -#pragma mark Implementation - -- (void)startParsing { - NSLog(@"startParsing"); - //self.navigationItem.rightBarButtonItem.enabled = NO; - // Reset the title - //self.title = NSLocalizedString(@"Getting Recent Picdumps...", @"Loading"); - // Allocate the array for song storage, or empty the results of previous parses - if (topics == nil) { - self.topics = [NSMutableArray array]; - } else { - [topics removeAllObjects]; - [self.tableView reloadData]; - } - // Create the parser, set its delegate, and start it. - self.parser = [[[AcidCowFeedburnerParser alloc] init] autorelease]; - parser.delegate = self; - [parser start]; -} - -- (void)parserDidEndParsingData:(XMLParser *)parser { - //self.title = [NSString stringWithFormat:NSLocalizedString(@"Recent Picdumps (%d)", @"Recent"), [topics count]]; - [self.tableView reloadData]; - //self.navigationItem.rightBarButtonItem.enabled = YES; - self.parser = nil; -} - -- (void)parser:(XMLParser *)parser didParseTopics:(NSArray *)parsedTopics { - [self updateTopicsFromWeb:parsedTopics]; - - // Three scroll view properties are checked to keep the user interface smooth during parse. When new objects are delivered - // by the parser, the table view is reloaded to display them. If the table is reloaded while - // the user is scrolling, this can result in eratic behavior. dragging, tracking, and decelerating can be checked - // for this purpose. When the parser finishes, reloadData will be called in parserDidEndParsingData:, guaranteeing - // that all data will ultimately be displayed even if reloadData is not called in this method because of user interaction. - if (!self.tableView.dragging && !self.tableView.tracking && !self.tableView.decelerating) { - //self.title = [NSString stringWithFormat:NSLocalizedString(@"Recent Picdumps (%d)", @"Recent"), [topics count]]; - [self.tableView reloadData]; - } -} - -- (void)parser:(XMLParser *)parser didFailWithError:(NSError *)error { - // handle errors as appropriate to your application... -} +// +//#pragma mark Implementation +// +//- (void)startParsing { +// NSLog(@"startParsing"); +// //self.navigationItem.rightBarButtonItem.enabled = NO; +// // Reset the title +// //self.title = NSLocalizedString(@"Getting Recent Picdumps...", @"Loading"); +// // Allocate the array for song storage, or empty the results of previous parses +// if (topics == nil) { +// self.topics = [NSMutableArray array]; +// } else { +// [topics removeAllObjects]; +// [self.tableView reloadData]; +// } +// // Create the parser, set its delegate, and start it. +// self.parser = [[[AcidCowFeedburnerParser alloc] init] autorelease]; +// parser.delegate = self; +// [parser start]; +//} +// +//- (void)parserDidEndParsingData:(XMLParser *)parser { +// //self.title = [NSString stringWithFormat:NSLocalizedString(@"Recent Picdumps (%d)", @"Recent"), [topics count]]; +// [self.tableView reloadData]; +// //self.navigationItem.rightBarButtonItem.enabled = YES; +// self.parser = nil; +//} +// +//- (void)parser:(XMLParser *)parser didParseTopics:(NSArray *)parsedTopics { +// [self updateTopicsFromWeb:parsedTopics]; +// +// // Three scroll view properties are checked to keep the user interface smooth during parse. When new objects are delivered +// // by the parser, the table view is reloaded to display them. If the table is reloaded while +// // the user is scrolling, this can result in eratic behavior. dragging, tracking, and decelerating can be checked +// // for this purpose. When the parser finishes, reloadData will be called in parserDidEndParsingData:, guaranteeing +// // that all data will ultimately be displayed even if reloadData is not called in this method because of user interaction. +// if (!self.tableView.dragging && !self.tableView.tracking && !self.tableView.decelerating) { +// //self.title = [NSString stringWithFormat:NSLocalizedString(@"Recent Picdumps (%d)", @"Recent"), [topics count]]; +// [self.tableView reloadData]; +// } +//} +// +//- (void)parser:(XMLParser *)parser didFailWithError:(NSError *)error { +// // handle errors as appropriate to your application... +//} #pragma mark - #pragma mark Memory management @@ -406,11 +433,9 @@ - (void)dealloc { [db release]; + [sourcesDictionary release]; [tableDictionary release]; [objMan release]; - [topics release]; - //[detailController release]; - [parser release]; [super dealloc]; } -- cgit v1.2.3