diff options
author | Struan Donald <struan@exo.org.uk> | 2013-03-25 15:57:26 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-03-25 17:13:56 +0000 |
commit | 73e3d5d4077636487f07be1beff3b2714ee2b276 (patch) | |
tree | 4b4529f36ab68ec7c2a9e51bcfafbd57d9336cc8 /iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m | |
parent | e5d7b3b62be5025f31c39b50ea3955398bc7cf40 (diff) |
upgrade to phonegap 2.5 for ios
Diffstat (limited to 'iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m')
-rwxr-xr-x | iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m index 833baad..6c7a856 100755 --- a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m +++ b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m @@ -18,7 +18,8 @@ */ #import "CDVInvokedUrlCommand.h" -#import "JSONKit.h" +#import "CDVJSON.h" +#import "NSData+Base64.h" @implementation CDVInvokedUrlCommand @@ -58,9 +59,36 @@ _className = className; _methodName = methodName; } + [self massageArguments]; return self; } +- (void)massageArguments +{ + NSMutableArray* newArgs = nil; + + for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) { + id arg = [_arguments objectAtIndex:i]; + if (![arg isKindOfClass:[NSDictionary class]]) { + continue; + } + NSDictionary* dict = arg; + NSString* type = [dict objectForKey:@"CDVType"]; + if (!type || ![type isEqualToString:@"ArrayBuffer"]) { + continue; + } + NSString* data = [dict objectForKey:@"data"]; + if (!data) { + continue; + } + if (newArgs == nil) { + newArgs = [NSMutableArray arrayWithArray:_arguments]; + _arguments = newArgs; + } + [newArgs replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]]; + } +} + - (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict { NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments]; |