diff --git a/Classes/BWGlobal.m b/Classes/BWGlobal.m
index 7f9e8e45d5..d967d5a9b7 100644
--- a/Classes/BWGlobal.m
+++ b/Classes/BWGlobal.m
@@ -36,10 +36,10 @@ NSBundle *hockeyBundle(void) {
}
NSString *BWmd5(NSString *str) {
- const char *cStr = [str UTF8String];
- unsigned char result[CC_MD5_DIGEST_LENGTH];
- CC_MD5( cStr, strlen(cStr), result );
- return [NSString
+ const char *cStr = [str UTF8String];
+ unsigned char result[CC_MD5_DIGEST_LENGTH];
+ CC_MD5( cStr, strlen(cStr), result );
+ return [NSString
stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1],
result[2], result[3],
diff --git a/Classes/BWHockeySettingsViewController.m b/Classes/BWHockeySettingsViewController.m
index 34d94591e2..8ceddb3513 100644
--- a/Classes/BWHockeySettingsViewController.m
+++ b/Classes/BWHockeySettingsViewController.m
@@ -62,7 +62,7 @@
}
- (id)init {
- return [self init:[BWHockeyManager sharedHockeyManager]];
+ return [self init:[BWHockeyManager sharedHockeyManager]];
}
#pragma mark -
diff --git a/Classes/BWHockeyViewController.m b/Classes/BWHockeyViewController.m
index 2ac45cc329..92ad3dafd3 100644
--- a/Classes/BWHockeyViewController.m
+++ b/Classes/BWHockeyViewController.m
@@ -295,26 +295,26 @@
}
- (CAGradientLayer *)backgroundLayer {
- UIColor *colorOne = [UIColor colorWithWhite:0.9 alpha:1.0];
- UIColor *colorTwo = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.85 alpha:1.0];
- UIColor *colorThree = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.7 alpha:1.0];
- UIColor *colorFour = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.4 alpha:1.0];
+ UIColor *colorOne = [UIColor colorWithWhite:0.9 alpha:1.0];
+ UIColor *colorTwo = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.85 alpha:1.0];
+ UIColor *colorThree = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.7 alpha:1.0];
+ UIColor *colorFour = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.4 alpha:1.0];
- NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, colorThree.CGColor, colorFour.CGColor, nil];
+ NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, colorThree.CGColor, colorFour.CGColor, nil];
- NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
- NSNumber *stopTwo = [NSNumber numberWithFloat:0.02];
- NSNumber *stopThree = [NSNumber numberWithFloat:0.99];
- NSNumber *stopFour = [NSNumber numberWithFloat:1.0];
+ NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
+ NSNumber *stopTwo = [NSNumber numberWithFloat:0.02];
+ NSNumber *stopThree = [NSNumber numberWithFloat:0.99];
+ NSNumber *stopFour = [NSNumber numberWithFloat:1.0];
- NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, stopThree, stopFour, nil];
+ NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, stopThree, stopFour, nil];
- CAGradientLayer *headerLayer = [CAGradientLayer layer];
- //headerLayer.frame = CGRectMake(0.0, 0.0, 320.0, 77.0);
- headerLayer.colors = colors;
- headerLayer.locations = locations;
+ CAGradientLayer *headerLayer = [CAGradientLayer layer];
+ //headerLayer.frame = CGRectMake(0.0, 0.0, 320.0, 77.0);
+ headerLayer.colors = colors;
+ headerLayer.locations = locations;
- return headerLayer;
+ return headerLayer;
}
- (void)viewDidLoad {
diff --git a/Classes/BWQuincyManager.h b/Classes/BWQuincyManager.h
index 23d9fa0230..e4accd4068 100644
--- a/Classes/BWQuincyManager.h
+++ b/Classes/BWQuincyManager.h
@@ -54,31 +54,31 @@ NSString *BWQuincyLocalize(NSString *stringToken);
#define BWQuincyNetworkBecomeReachable @"NetworkDidBecomeReachable"
typedef enum QuincyKitAlertType {
- QuincyKitAlertTypeSend = 0,
- QuincyKitAlertTypeFeedback = 1,
+ QuincyKitAlertTypeSend = 0,
+ QuincyKitAlertTypeFeedback = 1,
} CrashAlertType;
typedef enum CrashReportStatus {
// The status of the crash is queued, need to check later (HockeyApp)
- CrashReportStatusQueued = -80,
+ CrashReportStatusQueued = -80,
// This app version is set to discontinued, no new crash reports accepted by the server
- CrashReportStatusFailureVersionDiscontinued = -30,
+ CrashReportStatusFailureVersionDiscontinued = -30,
// XML: Sender version string contains not allowed characters, only alphanumberical including space and . are allowed
- CrashReportStatusFailureXMLSenderVersionNotAllowed = -21,
+ CrashReportStatusFailureXMLSenderVersionNotAllowed = -21,
// XML: Version string contains not allowed characters, only alphanumberical including space and . are allowed
- CrashReportStatusFailureXMLVersionNotAllowed = -20,
+ CrashReportStatusFailureXMLVersionNotAllowed = -20,
// SQL for adding a symoblicate todo entry in the database failed
- CrashReportStatusFailureSQLAddSymbolicateTodo = -18,
+ CrashReportStatusFailureSQLAddSymbolicateTodo = -18,
// SQL for adding crash log in the database failed
- CrashReportStatusFailureSQLAddCrashlog = -17,
+ CrashReportStatusFailureSQLAddCrashlog = -17,
// SQL for adding a new version in the database failed
- CrashReportStatusFailureSQLAddVersion = -16,
+ CrashReportStatusFailureSQLAddVersion = -16,
// SQL for checking if the version is already added in the database failed
CrashReportStatusFailureSQLCheckVersionExists = -15,
@@ -162,19 +162,19 @@ typedef enum CrashReportStatus {
NSString *_feedbackRequestID;
float _feedbackDelayInterval;
- NSMutableString *_contentOfProperty;
- CrashReportStatus _serverResult;
+ NSMutableString *_contentOfProperty;
+ CrashReportStatus _serverResult;
- int _analyzerStarted;
- NSString *_crashesDir;
+ int _analyzerStarted;
+ NSString *_crashesDir;
- BOOL _crashIdenticalCurrentVersion;
+ BOOL _crashIdenticalCurrentVersion;
BOOL _crashReportActivated;
- NSMutableArray *_crashFiles;
+ NSMutableArray *_crashFiles;
- NSMutableData *_responseData;
- NSInteger _statusCode;
+ NSMutableData *_responseData;
+ NSInteger _statusCode;
NSURLConnection *_urlConnection;
diff --git a/Classes/BWQuincyManager.m b/Classes/BWQuincyManager.m
index 40c4f59636..fada70820d 100644
--- a/Classes/BWQuincyManager.m
+++ b/Classes/BWQuincyManager.m
@@ -92,8 +92,7 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
@synthesize appIdentifier = _appIdentifier;
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
-+(BWQuincyManager *)sharedQuincyManager
-{
++(BWQuincyManager *)sharedQuincyManager {
static BWQuincyManager *sharedInstance = nil;
static dispatch_once_t pred;
@@ -106,23 +105,23 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
}
#else
+ (BWQuincyManager *)sharedQuincyManager {
- static BWQuincyManager *quincyManager = nil;
+ static BWQuincyManager *quincyManager = nil;
- if (quincyManager == nil) {
- quincyManager = [[BWQuincyManager alloc] init];
- }
+ if (quincyManager == nil) {
+ quincyManager = [[BWQuincyManager alloc] init];
+ }
- return quincyManager;
+ return quincyManager;
}
#endif
- (id) init {
if ((self = [super init])) {
- _serverResult = CrashReportStatusUnknown;
- _crashIdenticalCurrentVersion = YES;
- _crashData = nil;
+ _serverResult = CrashReportStatusUnknown;
+ _crashIdenticalCurrentVersion = YES;
+ _crashData = nil;
_urlConnection = nil;
- _submissionURL = nil;
+ _submissionURL = nil;
_responseData = nil;
_appIdentifier = nil;
_sendingInProgress = NO;
@@ -130,63 +129,63 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
_didCrashInLastSession = NO;
_loggingEnabled = NO;
- self.delegate = nil;
+ self.delegate = nil;
self.feedbackActivated = NO;
self.showAlwaysButton = NO;
self.autoSubmitCrashReport = NO;
self.autoSubmitDeviceUDID = NO;
- NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitAnalyzerStarted];
- if (testValue) {
- _analyzerStarted = [[NSUserDefaults standardUserDefaults] integerForKey:kQuincyKitAnalyzerStarted];
- } else {
- _analyzerStarted = 0;
- }
+ NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitAnalyzerStarted];
+ if (testValue) {
+ _analyzerStarted = [[NSUserDefaults standardUserDefaults] integerForKey:kQuincyKitAnalyzerStarted];
+ } else {
+ _analyzerStarted = 0;
+ }
- testValue = nil;
- testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitActivated];
- if (testValue) {
- _crashReportActivated = [[NSUserDefaults standardUserDefaults] boolForKey:kQuincyKitActivated];
- } else {
- _crashReportActivated = YES;
- [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:kQuincyKitActivated];
- }
+ testValue = nil;
+ testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitActivated];
+ if (testValue) {
+ _crashReportActivated = [[NSUserDefaults standardUserDefaults] boolForKey:kQuincyKitActivated];
+ } else {
+ _crashReportActivated = YES;
+ [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:kQuincyKitActivated];
+ }
- if (_crashReportActivated) {
- _crashFiles = [[NSMutableArray alloc] init];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- _crashesDir = [[NSString stringWithFormat:@"%@", [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/crashes/"]] retain];
+ if (_crashReportActivated) {
+ _crashFiles = [[NSMutableArray alloc] init];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+ _crashesDir = [[NSString stringWithFormat:@"%@", [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/crashes/"]] retain];
- NSFileManager *fm = [NSFileManager defaultManager];
+ NSFileManager *fm = [NSFileManager defaultManager];
- if (![fm fileExistsAtPath:_crashesDir]) {
- NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedLong: 0755] forKey: NSFilePosixPermissions];
- NSError *theError = NULL;
+ if (![fm fileExistsAtPath:_crashesDir]) {
+ NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedLong: 0755] forKey: NSFilePosixPermissions];
+ NSError *theError = NULL;
- [fm createDirectoryAtPath:_crashesDir withIntermediateDirectories: YES attributes: attributes error: &theError];
- }
-
- PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
- NSError *error = NULL;
-
- // Check if we previously crashed
- if ([crashReporter hasPendingCrashReport]) {
- _didCrashInLastSession = YES;
- [self handleCrashReport];
+ [fm createDirectoryAtPath:_crashesDir withIntermediateDirectories: YES attributes: attributes error: &theError];
}
- // Enable the Crash Reporter
- if (![crashReporter enableCrashReporterAndReturnError: &error])
- NSLog(@"WARNING: Could not enable crash reporter: %@", error);
+ PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
+ NSError *error = NULL;
+
+ // Check if we previously crashed
+ if ([crashReporter hasPendingCrashReport]) {
+ _didCrashInLastSession = YES;
+ [self handleCrashReport];
+ }
+
+ // Enable the Crash Reporter
+ if (![crashReporter enableCrashReporterAndReturnError: &error])
+ NSLog(@"WARNING: Could not enable crash reporter: %@", error);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startManager) name:BWQuincyNetworkBecomeReachable object:nil];
- }
+ }
if (!quincyBundle()) {
- NSLog(@"WARNING: Quincy.bundle is missing, will send reports automatically!");
+ NSLog(@"WARNING: Quincy.bundle is missing, will send reports automatically!");
}
- }
- return self;
+ }
+ return self;
}
@@ -208,10 +207,10 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
[_crashData release];
- [_crashesDir release];
- [_crashFiles release];
+ [_crashesDir release];
+ [_crashFiles release];
- [super dealloc];
+ [super dealloc];
}
@@ -292,8 +291,8 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
if (!approvedCrashReports || [approvedCrashReports count] == 0) return YES;
- for (NSUInteger i=0; i < [_crashFiles count]; i++) {
- NSString *filename = [_crashFiles objectAtIndex:i];
+ for (NSUInteger i=0; i < [_crashFiles count]; i++) {
+ NSString *filename = [_crashFiles objectAtIndex:i];
if (![approvedCrashReports objectForKey:filename]) return YES;
}
@@ -330,46 +329,46 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
- (void) showCrashStatusMessage {
- UIAlertView *alertView = nil;
+ UIAlertView *alertView = nil;
- if (_serverResult >= CrashReportStatusAssigned &&
- _crashIdenticalCurrentVersion &&
- quincyBundle()) {
- // show some feedback to the user about the crash status
- NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
- switch (_serverResult) {
- case CrashReportStatusAssigned:
- alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
+ if (_serverResult >= CrashReportStatusAssigned &&
+ _crashIdenticalCurrentVersion &&
+ quincyBundle()) {
+ // show some feedback to the user about the crash status
+ NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
+ switch (_serverResult) {
+ case CrashReportStatusAssigned:
+ alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseNextRelease"), appName]
delegate: self
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
otherButtonTitles: nil];
- break;
- case CrashReportStatusSubmitted:
- alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
+ break;
+ case CrashReportStatusSubmitted:
+ alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseWaitingApple"), appName]
delegate: self
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
otherButtonTitles: nil];
- break;
- case CrashReportStatusAvailable:
- alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
+ break;
+ case CrashReportStatusAvailable:
+ alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseAvailable"), appName]
delegate: self
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
otherButtonTitles: nil];
- break;
- default:
- alertView = nil;
- break;
- }
+ break;
+ default:
+ alertView = nil;
+ break;
+ }
- if (alertView) {
- [alertView setTag: QuincyKitAlertTypeFeedback];
- [alertView show];
- [alertView release];
- }
- }
+ if (alertView) {
+ [alertView setTag: QuincyKitAlertTypeFeedback];
+ [alertView show];
+ [alertView release];
+ }
+ }
}
@@ -410,40 +409,40 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
#pragma mark NSXMLParser
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
- if (qName) {
- elementName = qName;
- }
+ if (qName) {
+ elementName = qName;
+ }
- if ([elementName isEqualToString:@"result"]) {
- _contentOfProperty = [NSMutableString string];
+ if ([elementName isEqualToString:@"result"]) {
+ _contentOfProperty = [NSMutableString string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
- if (qName) {
- elementName = qName;
- }
+ if (qName) {
+ elementName = qName;
+ }
// open source implementation
- if ([elementName isEqualToString: @"result"]) {
- if ([_contentOfProperty intValue] > _serverResult) {
- _serverResult = (CrashReportStatus)[_contentOfProperty intValue];
- } else {
+ if ([elementName isEqualToString: @"result"]) {
+ if ([_contentOfProperty intValue] > _serverResult) {
+ _serverResult = (CrashReportStatus)[_contentOfProperty intValue];
+ } else {
CrashReportStatus errorcode = (CrashReportStatus)[_contentOfProperty intValue];
- NSLog(@"CrashReporter ended in error code: %i", errorcode);
- }
- }
+ NSLog(@"CrashReporter ended in error code: %i", errorcode);
+ }
+ }
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
- if (_contentOfProperty) {
- // If the current element is one whose content we care about, append 'string'
- // to the property that holds the content of the current element.
- if (string != nil) {
- [_contentOfProperty appendString:string];
- }
- }
+ if (_contentOfProperty) {
+ // If the current element is one whose content we care about, append 'string'
+ // to the property that holds the content of the current element.
+ if (string != nil) {
+ [_contentOfProperty appendString:string];
+ }
+ }
}
#pragma mark -
@@ -451,13 +450,13 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
- (NSString *)_getDevicePlatform {
- size_t size = 0;
- sysctlbyname("hw.machine", NULL, &size, NULL, 0);
- char *answer = (char*)malloc(size);
- sysctlbyname("hw.machine", answer, &size, NULL, 0);
- NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
- free(answer);
- return platform;
+ size_t size = 0;
+ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+ char *answer = (char*)malloc(size);
+ sysctlbyname("hw.machine", answer, &size, NULL, 0);
+ NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
+ free(answer);
+ return platform;
}
- (NSString *)deviceIdentifier {
@@ -473,52 +472,52 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
NSMutableDictionary *approvedCrashReports = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey: kApprovedCrashReports]];
NSFileManager *fm = [NSFileManager defaultManager];
- NSError *error = NULL;
+ NSError *error = NULL;
- NSString *userid = @"";
- NSString *contact = @"";
- NSString *description = @"";
+ NSString *userid = @"";
+ NSString *contact = @"";
+ NSString *description = @"";
if (self.autoSubmitDeviceUDID && [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
userid = [self deviceIdentifier];
} else if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportUserID)]) {
- userid = [self.delegate crashReportUserID] ?: @"";
- }
+ userid = [self.delegate crashReportUserID] ?: @"";
+ }
- if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportContact)]) {
- contact = [self.delegate crashReportContact] ?: @"";
- }
+ if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportContact)]) {
+ contact = [self.delegate crashReportContact] ?: @"";
+ }
- if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportDescription)]) {
- description = [self.delegate crashReportDescription] ?: @"";
- }
+ if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportDescription)]) {
+ description = [self.delegate crashReportDescription] ?: @"";
+ }
NSMutableString *crashes = nil;
_crashIdenticalCurrentVersion = NO;
- for (NSUInteger i=0; i < [_crashFiles count]; i++) {
- NSString *filename = [_crashesDir stringByAppendingPathComponent:[_crashFiles objectAtIndex:i]];
- NSData *crashData = [NSData dataWithContentsOfFile:filename];
+ for (NSUInteger i=0; i < [_crashFiles count]; i++) {
+ NSString *filename = [_crashesDir stringByAppendingPathComponent:[_crashFiles objectAtIndex:i]];
+ NSData *crashData = [NSData dataWithContentsOfFile:filename];
- if ([crashData length] > 0) {
- PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
+ if ([crashData length] > 0) {
+ PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
if (report == nil) {
NSLog(@"Could not parse crash report");
continue;
}
- NSString *crashLogString = [PLCrashReportTextFormatter stringValueForCrashReport:report withTextFormat:PLCrashReportTextFormatiOS];
+ NSString *crashLogString = [PLCrashReportTextFormatter stringValueForCrashReport:report withTextFormat:PLCrashReportTextFormatiOS];
- if ([report.applicationInfo.applicationVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
- _crashIdenticalCurrentVersion = YES;
- }
+ if ([report.applicationInfo.applicationVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
+ _crashIdenticalCurrentVersion = YES;
+ }
if (crashes == nil) {
crashes = [NSMutableString string];
}
- [crashes appendFormat:@"%s%@%@%@%@%@%@%@",
+ [crashes appendFormat:@"%s%@%@%@%@%@%@%@",
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String],
report.applicationInfo.applicationIdentifier,
report.systemInfo.operatingSystemVersion,
@@ -528,16 +527,16 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
[crashLogString stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]>" options:NSLiteralSearch range:NSMakeRange(0,crashLogString.length)],
userid,
contact,
- [description stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]>" options:NSLiteralSearch range:NSMakeRange(0,description.length)]];
+ [description stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]>" options:NSLiteralSearch range:NSMakeRange(0,description.length)]];
// store this crash report as user approved, so if it fails it will retry automatically
[approvedCrashReports setObject:[NSNumber numberWithBool:YES] forKey:[_crashFiles objectAtIndex:i]];
- } else {
+ } else {
// we cannot do anything with this report, so delete it
[fm removeItemAtPath:filename error:&error];
}
- }
+ }
[[NSUserDefaults standardUserDefaults] setObject:approvedCrashReports forKey:kApprovedCrashReports];
[[NSUserDefaults standardUserDefaults] synchronize];
@@ -572,58 +571,60 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
- (void)_checkForFeedbackStatus {
NSMutableURLRequest *request = nil;
- request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes/%@",
- self.submissionURL,
- [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
- _feedbackRequestID
- ]
- ]];
+ request = [NSMutableURLRequest requestWithURL:
+ [NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes/%@",
+ self.submissionURL,
+ [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
+ _feedbackRequestID
+ ]
+ ]];
- [request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
- [request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
+ [request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
+ [request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
- [request setTimeoutInterval: 15];
- [request setHTTPMethod:@"GET"];
+ [request setTimeoutInterval: 15];
+ [request setHTTPMethod:@"GET"];
- _serverResult = CrashReportStatusUnknown;
- _statusCode = 200;
+ _serverResult = CrashReportStatusUnknown;
+ _statusCode = 200;
- // Release when done in the delegate method
- _responseData = [[NSMutableData alloc] init];
+ // Release when done in the delegate method
+ _responseData = [[NSMutableData alloc] init];
- if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
- [self.delegate connectionOpened];
- }
+ if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
+ [self.delegate connectionOpened];
+ }
- _urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
+ _urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
BWQuincyLog(@"Requesting feedback status.");
}
- (void)_postXML:(NSString*)xml toURL:(NSURL*)url {
- NSMutableURLRequest *request = nil;
+ NSMutableURLRequest *request = nil;
NSString *boundary = @"----FOO";
if (self.appIdentifier) {
- request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
- self.submissionURL,
- [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
- ]
- ]];
+ request = [NSMutableURLRequest requestWithURL:
+ [NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
+ self.submissionURL,
+ [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+ ]
+ ]];
} else {
request = [NSMutableURLRequest requestWithURL:url];
}
- [request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
- [request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
+ [request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
+ [request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
- [request setTimeoutInterval: 15];
- [request setHTTPMethod:@"POST"];
- NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
- [request setValue:contentType forHTTPHeaderField:@"Content-type"];
+ [request setTimeoutInterval: 15];
+ [request setHTTPMethod:@"POST"];
+ NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
+ [request setValue:contentType forHTTPHeaderField:@"Content-type"];
- NSMutableData *postBody = [NSMutableData data];
- [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+ NSMutableData *postBody = [NSMutableData data];
+ [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
if (self.appIdentifier) {
[postBody appendData:[@"Content-Disposition: form-data; name=\"xml\"; filename=\"crash.xml\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:@"Content-Type: text/xml\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
@@ -635,17 +636,17 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
[request setHTTPBody:postBody];
- _serverResult = CrashReportStatusUnknown;
- _statusCode = 200;
+ _serverResult = CrashReportStatusUnknown;
+ _statusCode = 200;
- //Release when done in the delegate method
- _responseData = [[NSMutableData alloc] init];
+ //Release when done in the delegate method
+ _responseData = [[NSMutableData alloc] init];
- if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
- [self.delegate connectionOpened];
- }
+ if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
+ [self.delegate connectionOpened];
+ }
- _urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
+ _urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (!_urlConnection) {
BWQuincyLog(@"Sending crash reports could not start!");
@@ -658,13 +659,13 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
#pragma mark NSURLConnection Delegate
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
- if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
- _statusCode = [(NSHTTPURLResponse *)response statusCode];
- }
+ if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
+ _statusCode = [(NSHTTPURLResponse *)response statusCode];
+ }
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- [_responseData appendData:data];
+ [_responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
@@ -754,15 +755,15 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
// Called to handle a pending crash report.
//
- (void) handleCrashReport {
- PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
- NSError *error = NULL;
+ PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
+ NSError *error = NULL;
// check if the next call ran successfully the last time
- if (_analyzerStarted == 0) {
- // mark the start of the routine
- _analyzerStarted = 1;
- [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
- [[NSUserDefaults standardUserDefaults] synchronize];
+ if (_analyzerStarted == 0) {
+ // mark the start of the routine
+ _analyzerStarted = 1;
+ [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
+ [[NSUserDefaults standardUserDefaults] synchronize];
// Try loading the crash report
_crashData = [[NSData alloc] initWithData:[crashReporter loadPendingCrashReportDataAndReturnError: &error]];
@@ -773,17 +774,17 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
NSLog(@"Could not load crash report: %@", error);
} else {
[_crashData writeToFile:[_crashesDir stringByAppendingPathComponent: cacheFilename] atomically:YES];
- }
- }
+ }
+ }
- // Purge the report
- // mark the end of the routine
- _analyzerStarted = 0;
- [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
+ // Purge the report
+ // mark the end of the routine
+ _analyzerStarted = 0;
+ [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
[[NSUserDefaults standardUserDefaults] synchronize];
- [crashReporter purgePendingCrashReport];
- return;
+ [crashReporter purgePendingCrashReport];
+ return;
}
diff --git a/Classes/CNSHockeyManager.m b/Classes/CNSHockeyManager.m
index 94c0007c59..2c216ebaf6 100644
--- a/Classes/CNSHockeyManager.m
+++ b/Classes/CNSHockeyManager.m
@@ -51,13 +51,13 @@
}
#else
+ (CNSHockeyManager *)sharedHockeyManager {
- static CNSHockeyManager *hockeyManager = nil;
+ static CNSHockeyManager *hockeyManager = nil;
- if (hockeyManager == nil) {
- hockeyManager = [[CNSHockeyManager alloc] init];
- }
+ if (hockeyManager == nil) {
+ hockeyManager = [[CNSHockeyManager alloc] init];
+ }
- return hockeyManager;
+ return hockeyManager;
}
#endif
diff --git a/Classes/NSString+HockeyAdditions.m b/Classes/NSString+HockeyAdditions.m
index a6483d4a07..d51776a9bf 100755
--- a/Classes/NSString+HockeyAdditions.m
+++ b/Classes/NSString+HockeyAdditions.m
@@ -51,29 +51,28 @@ CNS_FIX_CATEGORY_BUG(NSString_HockeyAdditions)
return result;
}
-- (NSComparisonResult)versionCompare:(NSString *)other
-{
- // Extract plain version number from self
- NSString *plainSelf = self;
- NSRange letterRange = [plainSelf rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
- if (letterRange.length)
- plainSelf = [plainSelf substringToIndex: letterRange.location];
+- (NSComparisonResult)versionCompare:(NSString *)other {
+ // Extract plain version number from self
+ NSString *plainSelf = self;
+ NSRange letterRange = [plainSelf rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
+ if (letterRange.length)
+ plainSelf = [plainSelf substringToIndex: letterRange.location];
- // Extract plain version number from other
- NSString *plainOther = other;
- letterRange = [plainOther rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
- if (letterRange.length)
- plainOther = [plainOther substringToIndex: letterRange.location];
+ // Extract plain version number from other
+ NSString *plainOther = other;
+ letterRange = [plainOther rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
+ if (letterRange.length)
+ plainOther = [plainOther substringToIndex: letterRange.location];
- // Compare plain versions
- NSComparisonResult result = [plainSelf compare:plainOther options:NSNumericSearch];
+ // Compare plain versions
+ NSComparisonResult result = [plainSelf compare:plainOther options:NSNumericSearch];
- // If plain versions are equal, compare full versions
- if (result == NSOrderedSame)
- result = [self compare:other options:NSNumericSearch];
+ // If plain versions are equal, compare full versions
+ if (result == NSOrderedSame)
+ result = [self compare:other options:NSNumericSearch];
- // Done
- return result;
+ // Done
+ return result;
}
@end
diff --git a/Classes/PSStoreButton.m b/Classes/PSStoreButton.m
index 629d74b3ce..2ffe73fee8 100644
--- a/Classes/PSStoreButton.m
+++ b/Classes/PSStoreButton.m
@@ -232,8 +232,8 @@
- (CGSize)sizeThatFits:(CGSize)size {
CGSize constr = (CGSize){.height = self.frame.size.height, .width = PS_MAX_WIDTH};
- CGSize newSize = [self.buttonData.label sizeWithFont:self.titleLabel.font constrainedToSize:constr lineBreakMode:UILineBreakModeMiddleTruncation];
- CGFloat newWidth = newSize.width + (PS_PADDING * 2);
+ CGSize newSize = [self.buttonData.label sizeWithFont:self.titleLabel.font constrainedToSize:constr lineBreakMode:UILineBreakModeMiddleTruncation];
+ CGFloat newWidth = newSize.width + (PS_PADDING * 2);
CGFloat newHeight = PS_MIN_HEIGHT > newSize.height ? PS_MIN_HEIGHT : newSize.height;
CGSize sizeThatFits = CGSizeMake(newWidth, newHeight);
@@ -250,7 +250,7 @@
rect.size.height = self.frame.size.height;
aLayer.frame = rect;
[aLayer layoutIfNeeded];
- }
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Classes/PSWebTableViewCell.m b/Classes/PSWebTableViewCell.m
index a6dfc475a9..98f730f25e 100644
--- a/Classes/PSWebTableViewCell.m
+++ b/Classes/PSWebTableViewCell.m
@@ -52,15 +52,15 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
#pragma mark private
- (void)addWebView {
- if(webViewContent_) {
+ if(webViewContent_) {
CGRect webViewRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
- if(!webView_) {
- webView_ = [[[UIWebView alloc] initWithFrame:webViewRect] retain];
- [self addSubview:webView_];
- webView_.hidden = YES;
- webView_.backgroundColor = self.cellBackgroundColor;
- webView_.opaque = NO;
- webView_.delegate = self;
+ if(!webView_) {
+ webView_ = [[[UIWebView alloc] initWithFrame:webViewRect] retain];
+ [self addSubview:webView_];
+ webView_.hidden = YES;
+ webView_.backgroundColor = self.cellBackgroundColor;
+ webView_.opaque = NO;
+ webView_.delegate = self;
webView_.autoresizingMask = UIViewAutoresizingFlexibleWidth;
for(UIView* subView in webView_.subviews){
@@ -79,32 +79,32 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
}
}
}
- else
- webView_.frame = webViewRect;
+ else
+ webView_.frame = webViewRect;
NSString *deviceWidth = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? [NSString stringWithFormat:@"%d", CGRectGetWidth(self.bounds)] : @"device-width";
//BWHockeyLog(@"%@\n%@\%@", PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent);
NSString *contentHtml = [NSString stringWithFormat:PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent];
- [webView_ loadHTMLString:contentHtml baseURL:nil];
- }
+ [webView_ loadHTMLString:contentHtml baseURL:nil];
+ }
}
- (void)showWebView {
- webView_.hidden = NO;
+ webView_.hidden = NO;
self.textLabel.text = @"";
- [self setNeedsDisplay];
+ [self setNeedsDisplay];
}
- (void)removeWebView {
- if(webView_) {
- webView_.delegate = nil;
- [webView_ resignFirstResponder];
- [webView_ removeFromSuperview];
- [webView_ release];
- }
- webView_ = nil;
- [self setNeedsDisplay];
+ if(webView_) {
+ webView_.delegate = nil;
+ [webView_ resignFirstResponder];
+ [webView_ removeFromSuperview];
+ [webView_ release];
+ }
+ webView_ = nil;
+ [self setNeedsDisplay];
}
@@ -163,15 +163,15 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
#pragma mark UIWebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
- if(navigationType == UIWebViewNavigationTypeOther)
- return YES;
+ if(navigationType == UIWebViewNavigationTypeOther)
+ return YES;
return NO;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
- if(webViewContent_)
+ if(webViewContent_)
[self showWebView];
CGRect frame = webView_.frame;
diff --git a/Classes/UIImage+HockeyAdditions.m b/Classes/UIImage+HockeyAdditions.m
index d0cdf2b26c..57ef986d5e 100644
--- a/Classes/UIImage+HockeyAdditions.m
+++ b/Classes/UIImage+HockeyAdditions.m
@@ -87,9 +87,9 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
- (UIImage *)bw_roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize {
// If the image does not have an alpha layer, add one
- UIImage *roundedImage = nil;
+ UIImage *roundedImage = nil;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- BW_IF_IOS4_OR_GREATER(
+ BW_IF_IOS4_OR_GREATER(
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0); // 0.0 for scale means "correct scale for device's main screen".
CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], CGRectMake(0, 0, self.size.width * self.scale, self.size.height * self.scale)); // cropping happens here.
@@ -224,20 +224,21 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
)
+
if (!image) {
- // Try older method.
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- CGContextRef context = CGBitmapContextCreate(NULL, scaledWidth, scaledHeight, 8, (fitSize.width * 4),
- colorSpace, kCGImageAlphaPremultipliedLast);
- CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], sourceRect);
- CGContextDrawImage(context, destRect, sourceImg);
- CGImageRelease(sourceImg);
- CGImageRef finalImage = CGBitmapContextCreateImage(context);
- CGContextRelease(context);
- CGColorSpaceRelease(colorSpace);
- image = [UIImage imageWithCGImage:finalImage];
- CGImageRelease(finalImage);
- }
+ // Try older method.
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGContextRef context = CGBitmapContextCreate(NULL, scaledWidth, scaledHeight, 8, (fitSize.width * 4),
+ colorSpace, kCGImageAlphaPremultipliedLast);
+ CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], sourceRect);
+ CGContextDrawImage(context, destRect, sourceImg);
+ CGImageRelease(sourceImg);
+ CGImageRef finalImage = CGBitmapContextCreateImage(context);
+ CGContextRelease(context);
+ CGColorSpaceRelease(colorSpace);
+ image = [UIImage imageWithCGImage:finalImage];
+ CGImageRelease(finalImage);
+ }
return image;
}
@@ -245,37 +246,37 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha, float toAlpha) {
- CGImageRef theCGImage = NULL;
+ CGImageRef theCGImage = NULL;
- // gradient is always black-white and the mask must be in the gray colorspace
+ // gradient is always black-white and the mask must be in the gray colorspace
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
- // create the bitmap context
- CGContextRef gradientBitmapContext = CGBitmapContextCreate(NULL, pixelsWide, pixelsHigh,
- 8, 0, colorSpace, kCGImageAlphaNone);
+ // create the bitmap context
+ CGContextRef gradientBitmapContext = CGBitmapContextCreate(NULL, pixelsWide, pixelsHigh,
+ 8, 0, colorSpace, kCGImageAlphaNone);
- // define the start and end grayscale values (with the alpha, even though
- // our bitmap context doesn't support alpha the gradient requires it)
- CGFloat colors[] = {toAlpha, 1.0, fromAlpha, 1.0};
+ // define the start and end grayscale values (with the alpha, even though
+ // our bitmap context doesn't support alpha the gradient requires it)
+ CGFloat colors[] = {toAlpha, 1.0, fromAlpha, 1.0};
- // create the CGGradient and then release the gray color space
- CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);
- CGColorSpaceRelease(colorSpace);
+ // create the CGGradient and then release the gray color space
+ CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);
+ CGColorSpaceRelease(colorSpace);
- // create the start and end points for the gradient vector (straight down)
- CGPoint gradientEndPoint = CGPointZero;
- CGPoint gradientStartPoint = CGPointMake(0, pixelsHigh);
+ // create the start and end points for the gradient vector (straight down)
+ CGPoint gradientEndPoint = CGPointZero;
+ CGPoint gradientStartPoint = CGPointMake(0, pixelsHigh);
- // draw the gradient into the gray bitmap context
- CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint,
+ // draw the gradient into the gray bitmap context
+ CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint,
gradientEndPoint, kCGGradientDrawsAfterEndLocation);
- CGGradientRelease(grayScaleGradient);
+ CGGradientRelease(grayScaleGradient);
- // convert the context into a CGImageRef and release the context
- theCGImage = CGBitmapContextCreateImage(gradientBitmapContext);
- CGContextRelease(gradientBitmapContext);
+ // convert the context into a CGImageRef and release the context
+ theCGImage = CGBitmapContextCreateImage(gradientBitmapContext);
+ CGContextRelease(gradientBitmapContext);
- // return the imageref containing the gradient
+ // return the imageref containing the gradient
return theCGImage;
}
@@ -293,29 +294,29 @@ CGContextRef MyOpenBitmapContext(int pixelsWide, int pixelsHigh) {
- (UIImage *)bw_reflectedImageWithHeight:(NSUInteger)height fromAlpha:(float)fromAlpha toAlpha:(float)toAlpha {
if(height == 0)
- return nil;
+ return nil;
- // create a bitmap graphics context the size of the image
- CGContextRef mainViewContentContext = MyOpenBitmapContext(self.size.width, height);
+ // create a bitmap graphics context the size of the image
+ CGContextRef mainViewContentContext = MyOpenBitmapContext(self.size.width, height);
- // create a 2 bit CGImage containing a gradient that will be used for masking the
- // main view content to create the 'fade' of the reflection. The CGImageCreateWithMask
- // function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient
- CGImageRef gradientMaskImage = CreateGradientImage(1, height, fromAlpha, toAlpha);
+ // create a 2 bit CGImage containing a gradient that will be used for masking the
+ // main view content to create the 'fade' of the reflection. The CGImageCreateWithMask
+ // function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient
+ CGImageRef gradientMaskImage = CreateGradientImage(1, height, fromAlpha, toAlpha);
- // create an image by masking the bitmap of the mainView content with the gradient view
- // then release the pre-masked content bitmap and the gradient bitmap
- CGContextClipToMask(mainViewContentContext, CGRectMake(0.0, 0.0, self.size.width, height), gradientMaskImage);
- CGImageRelease(gradientMaskImage);
+ // create an image by masking the bitmap of the mainView content with the gradient view
+ // then release the pre-masked content bitmap and the gradient bitmap
+ CGContextClipToMask(mainViewContentContext, CGRectMake(0.0, 0.0, self.size.width, height), gradientMaskImage);
+ CGImageRelease(gradientMaskImage);
- // draw the image into the bitmap context
- CGContextDrawImage(mainViewContentContext, CGRectMake(0, 0, self.size.width, self.size.height), self.CGImage);
+ // draw the image into the bitmap context
+ CGContextDrawImage(mainViewContentContext, CGRectMake(0, 0, self.size.width, self.size.height), self.CGImage);
- // convert the finished reflection image to a UIImage
- UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); // returns autoreleased
+ // convert the finished reflection image to a UIImage
+ UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); // returns autoreleased
UIGraphicsEndImageContext();
- return theImage;
+ return theImage;
}
- (id)bw_initWithContentsOfResolutionIndependentFile:(NSString *)path {
@@ -342,10 +343,10 @@ CGContextRef MyOpenBitmapContext(int pixelsWide, int pixelsHigh) {
+ (UIImage *)bw_imageNamed:(NSString *)imageName bundle:(NSString *)bundleName {
- NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
- NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];
- NSString *imagePath = [bundlePath stringByAppendingPathComponent:imageName];
- return [UIImage bw_imageWithContentsOfResolutionIndependentFile:imagePath];
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
+ NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];
+ NSString *imagePath = [bundlePath stringByAppendingPathComponent:imageName];
+ return [UIImage bw_imageWithContentsOfResolutionIndependentFile:imagePath];
}
@end