diff --git a/RNCalendarEvents.m b/RNCalendarEvents.m index 2783f30..90a7a03 100644 --- a/RNCalendarEvents.m +++ b/RNCalendarEvents.m @@ -30,10 +30,19 @@ @implementation RNCalendarEvents - (NSString *)hexStringFromColor:(UIColor *)color { const CGFloat *components = CGColorGetComponents(color.CGColor); - CGFloat r = components[0]; - CGFloat g = components[1]; - CGFloat b = components[2]; - + CGFloat r; + CGFloat g; + CGFloat b; + if(components && sizeof(components) >= 3){ + r = components[0]; + g = components[1]; + b = components[2]; + }else{ + r = 1; + g = 1; + b = 1; + } + return [NSString stringWithFormat:@"#%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), @@ -494,7 +503,7 @@ - (NSDictionary *)serializeCalendarEvent:(EKEvent *)event if (event.calendar) { [formedCalendarEvent setValue:@{ - @"id": event.calendar.calendarIdentifier, + @"id": event.calendar.calendarIdentifier?event.calendar.calendarIdentifier: @"tempCalendar", @"title": event.calendar.title ? event.calendar.title : @"", @"source": event.calendar.source && event.calendar.source.title ? event.calendar.source.title : @"", @"allowsModifications": @(event.calendar.allowsContentModifications), @@ -655,7 +664,7 @@ - (NSDictionary *)serializeCalendarEvent:(EKEvent *)event [formedCalendarEvent setValue:[self availabilityStringMatchingConstant:event.availability] forKey:_availability]; - if (event.structuredLocation) { + if (event.structuredLocation && event.structuredLocation.title && event.structuredLocation.radius) { NSMutableDictionary *structuredLocation = [[NSMutableDictionary alloc] initWithCapacity:3]; [structuredLocation addEntriesFromDictionary: @{ @"title": event.structuredLocation.title,