CB-9247 - Fixes compilation errors with cordova-ios 4.x

This commit is contained in:
Shazron Abdullah 2015-06-25 06:09:59 -07:00
parent 2e147ba9ca
commit b683315be6
2 changed files with 17 additions and 7 deletions

View File

@ -20,7 +20,6 @@
#import "CDVCamera.h" #import "CDVCamera.h"
#import "CDVJpegHeaderWriter.h" #import "CDVJpegHeaderWriter.h"
#import "UIImage+CropScaleOrientation.h" #import "UIImage+CropScaleOrientation.h"
#import <Cordova/NSData+Base64.h>
#import <ImageIO/CGImageProperties.h> #import <ImageIO/CGImageProperties.h>
#import <AssetsLibrary/ALAssetRepresentation.h> #import <AssetsLibrary/ALAssetRepresentation.h>
#import <AssetsLibrary/AssetsLibrary.h> #import <AssetsLibrary/AssetsLibrary.h>
@ -38,9 +37,20 @@ static NSSet* org_apache_cordova_validArrowDirections;
static NSString* toBase64(NSData* data) { static NSString* toBase64(NSData* data) {
SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString"); SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString");
SEL s2 = NSSelectorFromString(@"base64EncodedString"); SEL s2 = NSSelectorFromString(@"base64EncodedString");
SEL realSel = [data respondsToSelector:s1] ? s1 : s2; SEL s3 = NSSelectorFromString(@"base64EncodedStringWithOptions:");
NSString* (*func)(id, SEL) = (void *)[data methodForSelector:realSel];
return func(data, realSel); if ([data respondsToSelector:s1]) {
NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s1];
return func(data, s1);
} else if ([data respondsToSelector:s1]) {
NSString* (*func)(id, SEL) = (void *)[data methodForSelector:s2];
return func(data, s2);
} else if ([data respondsToSelector:s3]) {
NSString* (*func)(id, SEL, NSUInteger) = (void *)[data methodForSelector:s3];
return func(data, s3, 0);
} else {
return nil;
}
} }
@implementation CDVPictureOptions @implementation CDVPictureOptions

View File

@ -476,7 +476,7 @@
pictureOptions.encodingType = EncodingTypePNG; pictureOptions.encodingType = EncodingTypePNG;
resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataPNG base64EncodedString]); XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataPNG base64EncodedStringWithOptions:0]);
// Original, JPEG, full quality // Original, JPEG, full quality
@ -487,7 +487,7 @@
pictureOptions.encodingType = EncodingTypeJPEG; pictureOptions.encodingType = EncodingTypeJPEG;
resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataJPEG base64EncodedString]); XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataJPEG base64EncodedStringWithOptions:0]);
// Original, JPEG, with quality value // Original, JPEG, with quality value
@ -500,7 +500,7 @@
NSData* originalImageDataJPEGWithQuality = UIImageJPEGRepresentation(originalImage, [pictureOptions.quality floatValue]/ 100.f); NSData* originalImageDataJPEGWithQuality = UIImageJPEGRepresentation(originalImage, [pictureOptions.quality floatValue]/ 100.f);
resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions]; resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataJPEGWithQuality base64EncodedString]); XCTAssertEqualObjects([resultData base64EncodedStringWithOptions:0], [originalImageDataJPEGWithQuality base64EncodedStringWithOptions:0]);
// TODO: usesGeolocation is not tested // TODO: usesGeolocation is not tested
} }