You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/11/28 00:48:40 UTC
ios commit: Added new CDVInvokedUrlCommand argumentAtIndex method to
ensure proper object type returned (if not, default is returned)
Updated Branches:
refs/heads/master 093c98263 -> 6739488a4
Added new CDVInvokedUrlCommand argumentAtIndex method to ensure proper object type returned (if not, default is returned)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/6739488a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/6739488a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/6739488a
Branch: refs/heads/master
Commit: 6739488a4816b421369481be5983c3a10be8450e
Parents: 093c982
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Nov 27 15:48:34 2012 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Nov 27 15:48:34 2012 -0800
----------------------------------------------------------------------
CordovaLib/Classes/CDVInvokedUrlCommand.h | 2 ++
CordovaLib/Classes/CDVInvokedUrlCommand.m | 8 ++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6739488a/CordovaLib/Classes/CDVInvokedUrlCommand.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.h b/CordovaLib/Classes/CDVInvokedUrlCommand.h
index 178b749..6eb0099 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.h
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.h
@@ -51,5 +51,7 @@
- (id)argumentAtIndex:(NSUInteger)index;
// Same as above, but returns defaultValue instead of nil.
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue;
+// Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue
+- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass;
@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6739488a/CordovaLib/Classes/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index d79df50..833baad 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m
@@ -91,6 +91,11 @@
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue
{
+ return [self argumentAtIndex:index withDefault:defaultValue andClass:nil];
+}
+
+- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass
+{
if (index >= [_arguments count]) {
return defaultValue;
}
@@ -98,6 +103,9 @@
if (ret == [NSNull null]) {
ret = defaultValue;
}
+ if ((aClass != nil) && ![ret isKindOfClass:aClass]) {
+ ret = defaultValue;
+ }
return ret;
}