diff --git a/Photo/Synced+Methods.m b/Photo/Synced+Methods.m index 61df156..df477b5 100644 --- a/Photo/Synced+Methods.m +++ b/Photo/Synced+Methods.m @@ -20,7 +20,7 @@ #import "Synced+Methods.h" -@implementation Synced (Methods) +@implementation Synced (Methods) // // Constast for sync uploaded diff --git a/Photo/Timeline+Methods.m b/Photo/Timeline+Methods.m index 787e476..f812863 100644 --- a/Photo/Timeline+Methods.m +++ b/Photo/Timeline+Methods.m @@ -236,14 +236,30 @@ + (void) insertIntoCoreData:(NSArray *) rawNewestPhotos InManagedObjectContext:( photo.permission = [NSNumber numberWithBool:NO]; // latitude + // TODO: API does not return the number in float sometimes, + // in this case the framework will convert the NSString to NSDecimal + // https://github.com/photo/frontend/issues/1402 NSString *latitude = [raw objectForKey:@"latitude"]; - if ([latitude class] != [NSNull class] && ![latitude isEqualToString:@""]) - photo.latitude = latitude; + if ([latitude class] != [NSNull class]){ + if ( [latitude isKindOfClass: [NSString class]] && ![latitude isEqualToString:@""]) { + photo.latitude = latitude; + }else if ( [latitude isKindOfClass: [NSNumber class]] ) { + photo.latitude = [((NSNumber*)latitude) stringValue]; + } + } // longitude + // TODO: API does not return the number in float sometimes, + // in this case the framework will convert the NSString to NSDecimal + // https://github.com/photo/frontend/issues/1402 NSString *longitude = [raw objectForKey:@"longitude"]; - if ([longitude class] != [NSNull class] && ![longitude isEqualToString:@""]) - photo.longitude = longitude; + if ([longitude class] != [NSNull class]){ + if ( [longitude isKindOfClass: [NSString class]] && ![longitude isEqualToString:@""]) { + photo.longitude = longitude; + }else if ( [longitude isKindOfClass: [NSNumber class]] ) { + photo.longitude = [((NSNumber*)longitude) stringValue]; + } + } // get the date since 1970 double dUpload = [[raw objectForKey:@"dateUploaded"] doubleValue];