X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/06d14de207c7c4454bdc75efcefe01e63e93e16d..8e2c6c3f7d3846883f20754a84d03866057df427:/src/html/htmlctrl/webkit/webkit.mm diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index d6a4e6fe7d..0d65ecbe06 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -682,18 +682,20 @@ wxString wxWebKitCtrl::RunScript(const wxString& javascript){ id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )]; NSString* resultAsString; - NSString* className = NSStringFromClass([result class]); - if ([className isEqualToString:@"NSCFNumber"]) - resultAsString = [NSString stringWithFormat:@"%@", result]; - else if ([className isEqualToString:@"NSCFString"]) - resultAsString = result; - else if ([className isEqualToString:@"NSCFBoolean"]){ - if ([result boolValue]) - resultAsString = @"true"; + if ([result isKindOfClass:[NSNumber class]]){ + // __NSCFBoolean is a subclass of NSNumber + if (strcmp([result objCType], @encode(BOOL)) == 0){ + if ([result boolValue]) + resultAsString = @"true"; + else + resultAsString = @"false"; + } else - resultAsString = @"false"; + resultAsString = [NSString stringWithFormat:@"%@", result]; } - else if ([className isEqualToString:@"WebScriptObject"]) + else if ([result isKindOfClass:[NSString class]]) + resultAsString = result; + else if ([result isKindOfClass:[WebScriptObject class]]) resultAsString = [result stringRepresentation]; else return wxString(); // This can happen, see e.g. #12361.