From 663d25e5160e97eefed1444bac0b4ac964f3368e Mon Sep 17 00:00:00 2001 From: matt handler Date: Sun, 24 Apr 2011 21:00:46 -0400 Subject: still a bit off from a solid state... added fmdatabase, updated acidcow parser with a formate, added some standard stuff to piccast app delegate, created a section dictionary, did some serializing to/from db for topics, added a bunch of logic to topic view controller, added db table --- Classes/SectionDictionary.m | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Classes/SectionDictionary.m (limited to 'Classes/SectionDictionary.m') diff --git a/Classes/SectionDictionary.m b/Classes/SectionDictionary.m new file mode 100644 index 0000000..8845b2b --- /dev/null +++ b/Classes/SectionDictionary.m @@ -0,0 +1,64 @@ +// +// SectionDictionary.m +// PicCast +// +// Created by Matthew Handler on 4/23/11. +// Copyright 2011 Earl Industries. All rights reserved. +// + +#import "SectionDictionary.h" + + +@implementation SectionDictionary + +//@synthesize index; + +- (SectionDictionary *) init { + index = 0; + indexMap = [[[NSMutableDictionary alloc] init] retain]; + theRealDictionary = [[[NSMutableDictionary alloc] init] retain]; + [super init]; + + return self; +} + +- (id)forwardingTargetForSelector:(SEL)aSelector +{ + return theRealDictionary; +} + +- (void) setObject:(id)anObject forKey:(id)aKey { + [indexMap setObject:aKey forKey:[NSString stringWithFormat:@"%d", index]]; + index++; + [theRealDictionary setObject:anObject forKey:aKey]; +} + +// lets you push objects into sections without worry about storage +- (void) appendObject:(id)anObject forKey:(id)aKey { + NSMutableArray *store = [theRealDictionary objectForKey:aKey]; + if (store == nil) { + NSMutableArray *store = [[[NSMutableArray alloc] init] autorelease]; + [store addObject:anObject]; + [theRealDictionary setObject:store forKey:aKey]; + } + else [store addObject:anObject]; + + NSLog(@"number of rows: %d", [[theRealDictionary objectForKey:aKey] count]); +} + +- (id) objectForIndex:(NSInteger)i { + return [theRealDictionary objectForKey:[indexMap objectForKey:[NSString stringWithFormat:@"%d", i]]]; +} + +- (NSString *) keyForIndex:(NSInteger)i { + return [indexMap objectForKey:[NSString stringWithFormat:@"%d", i]]; +} + +- (void) dealloc { + [theRealDictionary release]; + [indexMap release]; + [super dealloc]; +} + + +@end -- cgit v1.2.3