From 1f6cc3f84a0b28157c6445d6657799d064d3720a Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Mon, 24 Nov 2014 15:14:08 +0100 Subject: [PATCH] Fix a few compiler warnings This fixes a few compiler warnings when compiling using iOS 8 as deployment target. Default is still iOS 6! --- Classes/BITCrashManager.m | 52 +++++++++++----------- Classes/BITFeedbackComposeViewController.m | 12 ++++- Classes/BITFeedbackListViewCell.m | 5 +++ Classes/BITImageAnnotationViewController.m | 5 +++ Classes/HockeySDKPrivate.h | 4 ++ 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 30e37aa803..1b766bcc32 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -197,19 +197,19 @@ static PLCrashReporterCallbacks plCrashCallbacks = { * This saves the list of approved crash reports */ - (void)saveSettings { - NSString *errorString = nil; + NSError *error = nil; NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:2]; if (_approvedCrashReports && [_approvedCrashReports count] > 0) { [rootObj setObject:_approvedCrashReports forKey:kBITCrashApprovedReports]; } - NSData *plist = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj - format:NSPropertyListBinaryFormat_v1_0 - errorDescription:&errorString]; + + NSData *plist = [NSPropertyListSerialization dataWithPropertyList:(id)rootObj format:NSPropertyListBinaryFormat_v1_0 options:0 error:&error]; + if (plist) { [plist writeToFile:_settingsFile atomically:YES]; } else { - BITHockeyLog(@"ERROR: Writing settings. %@", errorString); + BITHockeyLog(@"ERROR: Writing settings. %@", [error description]); } } @@ -219,7 +219,7 @@ static PLCrashReporterCallbacks plCrashCallbacks = { * This contains the list of approved crash reports */ - (void)loadSettings { - NSString *errorString = nil; + NSError *error = nil; NSPropertyListFormat format; if (![_fileManager fileExistsAtPath:_settingsFile]) @@ -228,10 +228,10 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSData *plist = [NSData dataWithContentsOfFile:_settingsFile]; if (plist) { NSDictionary *rootObj = (NSDictionary *)[NSPropertyListSerialization - propertyListFromData:plist - mutabilityOption:NSPropertyListMutableContainersAndLeaves + propertyListWithData:plist + options:NSPropertyListMutableContainersAndLeaves format:&format - errorDescription:&errorString]; + error:&error]; if ([rootObj objectForKey:kBITCrashApprovedReports]) [_approvedCrashReports setDictionary:[rootObj objectForKey:kBITCrashApprovedReports]]; @@ -689,7 +689,6 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSError *error = NULL; NSMutableDictionary *metaDict = [NSMutableDictionary dictionaryWithCapacity:4]; NSString *applicationLog = @""; - NSString *errorString = nil; [self addStringValueToKeychain:[self userNameForCrashReport] forKey:[NSString stringWithFormat:@"%@.%@", filename, kBITCrashMetaUserName]]; [self addStringValueToKeychain:[self userEmailForCrashReport] forKey:[NSString stringWithFormat:@"%@.%@", filename, kBITCrashMetaUserEmail]]; @@ -708,9 +707,10 @@ static PLCrashReporterCallbacks plCrashCallbacks = { } } - NSData *plist = [NSPropertyListSerialization dataFromPropertyList:(id)metaDict + NSData *plist = [NSPropertyListSerialization dataWithPropertyList:(id)metaDict format:NSPropertyListBinaryFormat_v1_0 - errorDescription:&errorString]; + options:0 + error:&error]; if (plist) { [plist writeToFile:[_crashesDir stringByAppendingPathComponent: [filename stringByAppendingPathExtension:@"meta"]] atomically:YES]; } else { @@ -1173,7 +1173,7 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSString *fakeReportFilename = [NSString stringWithFormat: @"%.0f", [NSDate timeIntervalSinceReferenceDate]]; - NSString *errorString = nil; + NSError *error = nil; NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:2]; [rootObj setObject:fakeReportUUID forKey:kBITFakeCrashUUID]; @@ -1196,15 +1196,16 @@ static PLCrashReporterCallbacks plCrashCallbacks = { appBuild:fakeReportAppVersion ]; - NSData *plist = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj + NSData *plist = [NSPropertyListSerialization dataWithPropertyList:(id)rootObj format:NSPropertyListBinaryFormat_v1_0 - errorDescription:&errorString]; + options:0 + error:&error]; if (plist) { if ([plist writeToFile:[_crashesDir stringByAppendingPathComponent:[fakeReportFilename stringByAppendingPathExtension:@"fake"]] atomically:YES]) { [self storeMetaDataForCrashReportFilename:fakeReportFilename]; } } else { - BITHockeyLog(@"ERROR: Writing fake crash report. %@", errorString); + BITHockeyLog(@"ERROR: Writing fake crash report. %@", [error description]); } } @@ -1240,15 +1241,14 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSString *appBinaryUUIDs = nil; NSString *metaFilename = nil; - NSString *errorString = nil; NSPropertyListFormat format; if ([[cacheFilename pathExtension] isEqualToString:@"fake"]) { NSDictionary *fakeReportDict = (NSDictionary *)[NSPropertyListSerialization - propertyListFromData:crashData - mutabilityOption:NSPropertyListMutableContainersAndLeaves + propertyListWithData:crashData + options:NSPropertyListMutableContainersAndLeaves format:&format - errorDescription:&errorString]; + error:&error]; crashLogString = [fakeReportDict objectForKey:kBITFakeCrashReport]; crashUUID = [fakeReportDict objectForKey:kBITFakeCrashUUID]; @@ -1307,10 +1307,10 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSData *plist = [NSData dataWithContentsOfFile:[_crashesDir stringByAppendingPathComponent:metaFilename]]; if (plist) { NSDictionary *metaDict = (NSDictionary *)[NSPropertyListSerialization - propertyListFromData:plist - mutabilityOption:NSPropertyListMutableContainersAndLeaves + propertyListWithData:plist + options:NSPropertyListMutableContainersAndLeaves format:&format - errorDescription:&errorString]; + error:&error]; username = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", cacheFilename, kBITCrashMetaUserName]] ?: @""; useremail = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", cacheFilename, kBITCrashMetaUserEmail]] ?: @""; @@ -1468,10 +1468,10 @@ static PLCrashReporterCallbacks plCrashCallbacks = { [strongSelf cleanCrashReportWithFilename:filename]; // HockeyApp uses PList XML format - NSMutableDictionary *response = [NSPropertyListSerialization propertyListFromData:responseData - mutabilityOption:NSPropertyListMutableContainersAndLeaves + NSMutableDictionary *response = [NSPropertyListSerialization propertyListWithData:responseData + options:NSPropertyListMutableContainersAndLeaves format:nil - errorDescription:NULL]; + error:&error]; BITHockeyLog(@"INFO: Received API response: %@", response); if (strongSelf.delegate != nil && diff --git a/Classes/BITFeedbackComposeViewController.m b/Classes/BITFeedbackComposeViewController.m index 985f280db0..72547424b5 100644 --- a/Classes/BITFeedbackComposeViewController.m +++ b/Classes/BITFeedbackComposeViewController.m @@ -144,9 +144,17 @@ NSDictionary* info = [aNotification userInfo]; CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; + BOOL isPortraitOrientation = NO; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 + isPortraitOrientation = UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); +#else + isPortraitOrientation = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) +#endif + CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { - if (!bit_isPreiOS8Environment() || UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { + if (!bit_isPreiOS8Environment() || isPortraitOrientation) { frame.size.height -= kbSize.height; } else { frame.size.height -= kbSize.width; @@ -156,7 +164,7 @@ CGFloat windowHeight = windowSize.height - 20; CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height; - if (!bit_isPreiOS8Environment() || UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { + if (!bit_isPreiOS8Environment() || isPortraitOrientation) { CGFloat modalGap = (windowHeight - self.view.bounds.size.height) / 2; frame.size.height = windowHeight - navBarHeight - kbSize.height; if (bit_isPreiOS8Environment()) { diff --git a/Classes/BITFeedbackListViewCell.m b/Classes/BITFeedbackListViewCell.m index 2e9519a01a..d55e27897f 100644 --- a/Classes/BITFeedbackListViewCell.m +++ b/Classes/BITFeedbackListViewCell.m @@ -134,7 +134,12 @@ - (BOOL)isSameDayWithDate1:(NSDate*)date1 date2:(NSDate*)date2 { NSCalendar* calendar = [NSCalendar currentCalendar]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 + unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; +#else unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; +#endif + NSDateComponents *dateComponent1 = [calendar components:unitFlags fromDate:date1]; NSDateComponents *dateComponent2 = [calendar components:unitFlags fromDate:date2]; diff --git a/Classes/BITImageAnnotationViewController.m b/Classes/BITImageAnnotationViewController.m index 1406996471..3fc15cb6ce 100644 --- a/Classes/BITImageAnnotationViewController.m +++ b/Classes/BITImageAnnotationViewController.m @@ -113,8 +113,13 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) { self.imageView.userInteractionEnabled = YES; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(discard:)]; + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(save:)]; +#else self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(discard:)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(save:)]; +#endif self.view.autoresizesSubviews = NO; } diff --git a/Classes/HockeySDKPrivate.h b/Classes/HockeySDKPrivate.h index 49d48646a7..49b9d28310 100644 --- a/Classes/HockeySDKPrivate.h +++ b/Classes/HockeySDKPrivate.h @@ -75,6 +75,10 @@ NSBundle *BITHockeyBundle(void); NSString *BITHockeyLocalizedString(NSString *stringToken); NSString *BITHockeyMD5(NSString *str); +#ifndef __IPHONE_8_0 +#define __IPHONE_8_0 80000 +#endif + #ifdef __IPHONE_6_0 #define kBITTextLabelAlignmentCenter NSTextAlignmentCenter