diff --git a/Pod/Classes/OMHHealthKitConstantsMapper.h b/Pod/Classes/OMHHealthKitConstantsMapper.h index 3bcd575..afca124 100644 --- a/Pod/Classes/OMHHealthKitConstantsMapper.h +++ b/Pod/Classes/OMHHealthKitConstantsMapper.h @@ -18,6 +18,5 @@ + (NSString*) stringForHKWorkoutActivityType:(int) enumValue; + (NSString*) stringForHKSleepAnalysisValue:(int) enumValue; -+ (NSDictionary*) dictionaryForTypeIdentifiersToClasses; @end diff --git a/Pod/Classes/OMHHealthKitConstantsMapper.m b/Pod/Classes/OMHHealthKitConstantsMapper.m index e698bdb..9df7e43 100644 --- a/Pod/Classes/OMHHealthKitConstantsMapper.m +++ b/Pod/Classes/OMHHealthKitConstantsMapper.m @@ -150,6 +150,14 @@ + (NSString*) stringForHKSleepAnalysisValue:(int) enumValue{ case HKCategoryValueSleepAnalysisAsleep: return @"Asleep"; break; + default:{ + NSException *e = [NSException + exceptionWithName:@"KCategoryValueSleepAnalysisInvalidValue" + reason:@"KCategoryValueSleepAnalysis can only have a HKCategoryValueSleepAnalysisInBed or HKCategoryValueSleepAnalysisAsleep value" + userInfo:nil]; + @throw e; + } + } } diff --git a/Pod/Classes/OMHSerializer.m b/Pod/Classes/OMHSerializer.m index 091e04b..322dc6f 100644 --- a/Pod/Classes/OMHSerializer.m +++ b/Pod/Classes/OMHSerializer.m @@ -832,10 +832,10 @@ @interface OMHSerializerGenericWorkout : OMHSerializer; @end @implementation OMHSerializerGenericWorkout + (BOOL)canSerialize:(HKSample *)sample error:(NSError *__autoreleasing *)error { - @try{ - HKWorkout *workoutSample = (HKWorkout*)sample; + if([sample isKindOfClass:[HKWorkout class]]){ + return YES; } - @catch (NSException *exception){ + else{ if (error) { NSString* errorMessage = @"OMHSerializerGenericWorkout is used for HKWorkout samples only"; @@ -846,7 +846,7 @@ + (BOOL)canSerialize:(HKSample *)sample error:(NSError *__autoreleasing *)error } return NO; } - return YES; + } - (id)bodyData {