Skip to content

Commit

Permalink
Prepare for Development branch
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Apr 1, 2011
1 parent 07898f0 commit 803a410
Show file tree
Hide file tree
Showing 33 changed files with 94 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Classes/AccountManager.m
Expand Up @@ -43,7 +43,7 @@ + (AccountManager *) sharedAccountManager

- (id) init
{
if (self = [super init])
if ((self = [super init]))
{
[self loadAllGenericAccounts];

Expand Down
2 changes: 1 addition & 1 deletion Classes/App.m
Expand Up @@ -51,7 +51,7 @@ @implementation App
- (id)init
{
// default images
if (self = [super init])
if ((self = [super init]))
{
self.iconImage = [UIImage imageNamed:@"Empty.png"];
UIImage *tmpImageNanoResized = [self.iconImage imageByScalingToSize:CGSizeMake(32.0,32.0)];
Expand Down
4 changes: 2 additions & 2 deletions Classes/AppGrouping.m
Expand Up @@ -24,7 +24,7 @@ @implementation AppGrouping

- (id) initWithAppSet:(NSSet *)appSet
{
if (self = [super init])
if ((self = [super init]))
{
apps = [[NSMutableSet alloc] initWithSet:appSet];
}
Expand Down Expand Up @@ -58,7 +58,7 @@ - (void)appendAppsOfSet:(NSSet *)appSet

#pragma mark Database
- (id)initWithPrimaryKey:(NSInteger)pk database:(sqlite3 *)db {
if (self = [super init])
if ((self = [super init]))
{
primaryKey = pk;
database = db;
Expand Down
2 changes: 1 addition & 1 deletion Classes/AppIconDownloadOperation.m
Expand Up @@ -13,7 +13,7 @@ @implementation AppIconDownloadOperation

- (id)initWithApplicationIdentifier:(NSInteger)appID
{
if (self = [super init])
if ((self = [super init]))
{
_appID = appID;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/AsyncSocket.m
Expand Up @@ -161,7 +161,7 @@ - (id)initWithData:(NSMutableData *)d
terminator:(NSData *)e
maxLength:(CFIndex)m
{
if(self = [super init])
if ((self = [super init]))
{
buffer = [d retain];
timeout = t;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ChartViewController.m
Expand Up @@ -30,7 +30,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

- (id)initWithChartData:(NSDictionary *)dataDict
{
if (self = [super init])
if ((self = [super init]))
{
UIView *rootView = [[UIView alloc] init];
self.view = rootView;
Expand Down
38 changes: 21 additions & 17 deletions Classes/CoreDatabase+Import_v1.m
Expand Up @@ -205,8 +205,6 @@ - (void)importDatabase:(Database *)database
// migrate reports separately
NSArray *allReports = [database allReports];

NSLog(@"%d reports", [allReports count]);

for (Report_v1 *oneReport in allReports)
{
// create a report for each
Expand All @@ -231,6 +229,9 @@ - (void)importDatabase:(Database *)database
[reportLookup setObject:report forKey:[NSNumber numberWithInt:oneReport.primaryKey]];
}

NSLog(@"%d reports imported", [allReports count]);
[self save];

// migrate sales separately
sqlite3_stmt *statement = nil;

Expand Down Expand Up @@ -287,23 +288,26 @@ - (void)importDatabase:(Database *)database
// don't need it any more
sqlite3_finalize(statement);

[self save];

// make summary right away as well
for (Report *oneReport in [reportLookup allValues])
{
[self buildSummaryForReport:oneReport];
}

// make product summaries
for (Product *oneProduct in [productLookup allValues])
{
if (![oneProduct.isInAppPurchase boolValue])
{
[self buildSummaryForProduct:oneProduct];
}
}

// TAKES TOO LONG!
// // make summary right away as well
// for (Report *oneReport in [reportLookup allValues])
// {
// [self buildSummaryForReport:oneReport];
// }

[self save];
// // make product summaries
// for (Product *oneProduct in [productLookup allValues])
// {
// if (![oneProduct.isInAppPurchase boolValue])
// {
// [self buildSummaryForProduct:oneProduct];
// }
// }
//
// [self save];

// export country plist
NSString *path = [NSString pathForFileInDocuments:@"countries.plist"];
Expand Down
4 changes: 3 additions & 1 deletion Classes/CoreDatabase.h
Expand Up @@ -28,6 +28,9 @@
NSMutableDictionary *flagDictionary;
NSMutableDictionary *iconDictionary;

// Country cache
NSMutableDictionary *countryDictionary;


// Core Data Stack
NSPersistentStoreCoordinator *persistentStoreCoordinator;
Expand All @@ -36,7 +39,6 @@


// caches
NSArray *countries;
NSMutableDictionary *newReportsByType;
NSMutableDictionary *newAppsByProductGroup;
}
Expand Down
56 changes: 34 additions & 22 deletions Classes/CoreDatabase.m
Expand Up @@ -38,7 +38,7 @@ + (CoreDatabase *)sharedInstance

- (id) init
{
if (self = [super init])
if ((self = [super init]))
{
NSLog(@"Connected to: %@", [[CoreDatabase databaseStoreUrl] path]);

Expand All @@ -62,6 +62,16 @@ - (id) init
newReportsByType = [[NSMutableDictionary alloc] init];
newAppsByProductGroup = [[NSMutableDictionary alloc] init];


NSArray *allCountries = [self allCountriesWithAppStore];
countryDictionary = [[NSMutableDictionary alloc] init];

for (Country *oneCountry in allCountries)
{
[countryDictionary setObject:oneCountry forKey:oneCountry.iso2];
[countryDictionary setObject:oneCountry forKey:oneCountry.iso3];
}

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willResignActive:)
name:UIApplicationWillResignActiveNotification
Expand All @@ -78,7 +88,7 @@ - (void)dealloc
[flagDictionary release];
[newReportsByType release];
[newAppsByProductGroup release];
[countries release];
[countryDictionary release];

[super dealloc];
}
Expand Down Expand Up @@ -452,28 +462,30 @@ - (Country *) countryForName:(NSString *)countryName

- (Country *) countryForCode:(NSString *)code
{
if ([code length]==2)
if ([code length]<=3)
{
// iso2 code
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Country" inManagedObjectContext:self.managedObjectContext];
[request setEntity:entity];
[request setFetchLimit:1];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"iso2 = %@", code];
[request setPredicate:predicate];

NSError *error;
NSArray *fetchResults = [managedObjectContext executeFetchRequest:request error:&error];
if (fetchResults == nil)
{
// Handle the error.
NSLog(@"Cannot resolve country code '%@', please report this to oliver@drobnik.com", code);
}

[request release];
return [countryDictionary objectForKey:code];

return [fetchResults lastObject];
// // iso2 code
// NSFetchRequest *request = [[NSFetchRequest alloc] init];
// NSEntityDescription *entity = [NSEntityDescription entityForName:@"Country" inManagedObjectContext:self.managedObjectContext];
// [request setEntity:entity];
// [request setFetchLimit:1];
//
// NSPredicate *predicate = [NSPredicate predicateWithFormat:@"iso2 = %@", code];
// [request setPredicate:predicate];
//
// NSError *error;
// NSArray *fetchResults = [managedObjectContext executeFetchRequest:request error:&error];
// if (fetchResults == nil)
// {
// // Handle the error.
// NSLog(@"Cannot resolve country code '%@', please report this to oliver@drobnik.com", code);
// }
//
// [request release];
//
// return [fetchResults lastObject];
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/CountryFlagDownloadOperation.m
Expand Up @@ -13,7 +13,7 @@ @implementation CountryFlagDownloadOperation

- (id)initWithISO3:(NSString *)iso3
{
if (self = [super init])
if ((self = [super init]))
{
self.iso3 = [iso3 lowercaseString];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/CountrySummary.m
Expand Up @@ -15,7 +15,7 @@ @implementation CountrySummary

- (id)initWithCountry:(Country_v1 *)cntry sumSales:(NSInteger)sales sumUpdates:(NSInteger)updates sumRefunds:(NSInteger)refunds
{
if (self = [super init])
if ((self = [super init]))
{
self.country = cntry;
self.sumSales = sales;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Country_v1.m
Expand Up @@ -32,7 +32,7 @@ @implementation Country_v1
// Creates the object with primary key and title is brought into memory.
- (id)initWithISO3:(NSString *)pk database:(sqlite3 *)db
{
if (self = [super init])
if ((self = [super init]))
{
self.iso3 = pk;
database = db;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Database.m
Expand Up @@ -71,7 +71,7 @@ + (Database *) sharedInstance

- (id) init
{
if (self = [super init])
if ((self = [super init]))
{
newReportsByType = [[NSMutableDictionary alloc] init];
appGroupings = [[NSMutableSet alloc] init];
Expand Down Expand Up @@ -304,7 +304,7 @@ - (void) bulkLoadReportsOfType:(ReportType)reportType

// try cache first

NSString *path = [NSString pathForFileInDocuments:[NSString stringWithFormat:@"index_cache_%d.dat", reportType]];
//NSString *path = [NSString pathForFileInDocuments:[NSString stringWithFormat:@"index_cache_%d.dat", reportType]];
//NSData *compressed = [NSData dataWithContentsOfFile:path];

// NSData *compressed;
Expand Down
4 changes: 2 additions & 2 deletions Classes/GenericAccount.m
Expand Up @@ -32,7 +32,7 @@ @implementation GenericAccount

- (id) initFromKeychainDictionary:(NSDictionary *)dict
{
if (self = [super init])
if ((self = [super init]))
{
account = [[dict objectForKey:(id)kSecAttrAccount] retain];
description = [[dict objectForKey:(id)kSecAttrDescription] retain];
Expand Down Expand Up @@ -66,7 +66,7 @@ - (id) initFromKeychainDictionary:(NSDictionary *)dict

- (id) initService:(NSString *)aService forUser:(NSString *)aUser
{
if (self = [super init])
if ((self = [super init]))
{
account = [aUser retain];
service = [aService retain];
Expand Down
2 changes: 1 addition & 1 deletion Classes/InAppPurchase.m
Expand Up @@ -39,7 +39,7 @@ - (void)dealloc

// Creates the object with primary key and title is brought into memory.
- (id)initWithPrimaryKey:(NSInteger)pk database:(sqlite3 *)db {
if (self = [super init])
if ((self = [super init]))
{
apple_identifier = pk;
database = db;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ItunesConnectDownloaderOperation.m
Expand Up @@ -30,7 +30,7 @@ @implementation ItunesConnectDownloaderOperation

- (id) initForAccount:(GenericAccount *)itcAccount
{
if (self = [super init])
if ((self = [super init]))
{
account = [itcAccount retain];

Expand Down
2 changes: 1 addition & 1 deletion Classes/MyAppSalesAppDelegate.m
Expand Up @@ -517,7 +517,7 @@ - (void) emptyCache

NSError *error=nil;

while (aString = [enu nextObject])
while ((aString = [enu nextObject]))
{
NSString *pathOfFile = [documentsDirectory stringByAppendingPathComponent:aString];

Expand Down
2 changes: 1 addition & 1 deletion Classes/NotificationsSubscribeOperation.m
Expand Up @@ -18,7 +18,7 @@ @implementation NotificationsSubscribeOperation

- (id) initForAccount:(GenericAccount *)notificationsAccount subscribe:(BOOL)doSubscribe;
{
if (self = [super init])
if ((self = [super init]))
{
account = [notificationsAccount retain];
workInProgress = YES;
Expand Down
2 changes: 1 addition & 1 deletion Classes/PinLockController.m
Expand Up @@ -22,7 +22,7 @@ @implementation PinLockController

- (id)initWithMode:(PinLockControllerMode)initMode
{
if (self = [super init])
if ((self = [super init]))
{
mode = initMode;

Expand Down
2 changes: 1 addition & 1 deletion Classes/Product_v1.m
Expand Up @@ -52,7 +52,7 @@ @implementation Product_v1
- (id)init
{
// default images
if (self = [super init])
if ((self = [super init]))
{
// subscribe to total update notifications
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appTotalsUpdated:) name:@"AppTotalsUpdated" object:nil];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Query.m
Expand Up @@ -16,7 +16,7 @@ @implementation Query

- (id)initWithDatabase:(sqlite3 *)db
{
if (self = [super init])
if ((self = [super init]))
{
database = db;
return self;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Report_v1.m
Expand Up @@ -49,7 +49,7 @@ @implementation Report_v1

-(id)init
{
if (self = [super init])
if ((self = [super init]))
{
dirty = NO;
hydrated = NO;
Expand Down Expand Up @@ -340,7 +340,7 @@ - (id)initAsFreeReportWithDict:(NSDictionary *)dict

- (id)initWithReportText:(NSString *)string
{
if (self = [super init])
if ((self = [super init]))
{
// Make a list of apps in this report
NSMutableSet *tmpAppsInReport = [NSMutableSet set];
Expand Down
2 changes: 1 addition & 1 deletion Classes/ReportsOverviewViewController.m
Expand Up @@ -30,7 +30,7 @@ @implementation ReportsOverviewViewController

- (id)initWithProductGroup:(ProductGroup *)productGroup reportType:(ReportType)reportType
{
if (self = [super initWithStyle:UITableViewStylePlain])
if ((self = [super initWithStyle:UITableViewStylePlain]))
{
_productGroup = [productGroup retain];
_reportType = reportType;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ReviewDownloaderOperation.m
Expand Up @@ -24,7 +24,7 @@ @implementation ReviewDownloaderOperation

- (id) initForAppID:(NSInteger)appID storeID:(NSInteger)storeID delegate:(NSObject <ReviewScraperDelegate> *) scrDelegate;
{
if (self = [super init])
if ((self = [super init]))
{
_appID = appID;
_storeID = storeID;
Expand Down

0 comments on commit 803a410

Please sign in to comment.