diff --git a/Build/Products/Debug-iphonesimulator/libdsbridge.a b/Build/Products/Debug-iphonesimulator/libdsbridge.a index 1651447..cc017e2 100644 Binary files a/Build/Products/Debug-iphonesimulator/libdsbridge.a and b/Build/Products/Debug-iphonesimulator/libdsbridge.a differ diff --git a/dsBridge.podspec b/dsBridge.podspec index d13e2c9..27d5839 100644 --- a/dsBridge.podspec +++ b/dsBridge.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "dsBridge" - s.version = "3.0.5" + s.version = "3.0.6" s.summary = "An ios bridge for calling functions synchronously and asynchronously between JavaScript and Object-C in WKWebView/UIWebView" # This description is used to generate tags and improve search results. diff --git a/dsbridge.xcodeproj/project.pbxproj b/dsbridge.xcodeproj/project.pbxproj index 70ff8b2..b9da3f3 100644 --- a/dsbridge.xcodeproj/project.pbxproj +++ b/dsbridge.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 812F1D3B216F1F9D00B5BD0C /* publish.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = publish.sh; sourceTree = ""; }; 8142EA1C214212E600BEE5C0 /* dsbridgedemo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dsbridgedemo-Bridging-Header.h"; sourceTree = ""; }; 8142EA1D214212E700BEE5C0 /* JsApiTestSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsApiTestSwift.swift; sourceTree = ""; }; 815612E92020304600C4F5CD /* InternalApis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InternalApis.h; sourceTree = ""; }; @@ -112,6 +113,7 @@ 818F0B851E18C08100679925 = { isa = PBXGroup; children = ( + 812F1D3B216F1F9D00B5BD0C /* publish.sh */, 81CFC867202C42AA00CF9D83 /* img */, 81CFC861202953CB00CF9D83 /* .travis.yml */, 81CFC85F2029456C00CF9D83 /* readme-chs.md */, diff --git a/dsbridge/DWKWebView.m b/dsbridge/DWKWebView.m index 9656317..1bfbbff 100644 --- a/dsbridge/DWKWebView.m +++ b/dsbridge/DWKWebView.m @@ -267,6 +267,7 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr do{ if(args && (cb= args[@"_dscbstub"])){ if([JavascriptInterfaceObject respondsToSelector:selasyn]){ + __weak typeof(self) weakSelf = self; void (^completionHandler)(id,BOOL) = ^(id value,BOOL complete){ NSString *del=@""; result[@"code"]=@0; @@ -280,18 +281,18 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr del=[@"delete window." stringByAppendingString:cb]; } NSString*js=[NSString stringWithFormat:@"try {%@(JSON.parse(decodeURIComponent(\"%@\")).data);%@; } catch(e){};",cb,(value == nil) ? @"" : value,del]; - + __strong typeof(self) strongSelf = weakSelf; @synchronized(self) { UInt64 t=[[NSDate date] timeIntervalSince1970]*1000; jsCache=[jsCache stringByAppendingString:js]; if(t-lastCallTime<50){ if(!isPending){ - [self evalJavascript:50]; + [strongSelf evalJavascript:50]; isPending=true; } }else{ - [self evalJavascript:0]; + [strongSelf evalJavascript:0]; } } diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..8fa8e16 --- /dev/null +++ b/publish.sh @@ -0,0 +1,2 @@ +#!/bin/sh +pod trunk push --allow-warnings