Explorar el Código

【APPCenter】Crash编号:0(阅读页广告 KMAdsWebView) -- 修复

lizhe hace 10 meses
padre
commit
37a1d33cd4

+ 6 - 8
PDF Office/PDF Master/Class/AD/KMAdsWebView.swift

@@ -280,26 +280,25 @@ class KMAdsWebView: NSView, WKNavigationDelegate, CAAnimationDelegate {
 
         if let completionHandler = self.completionHandler {
             completionHandler(currentPage + 1)
-            self.completionHandler = nil
         }
         removeFromSuperview()
     }
     
     @objc func buttonItemClicked(_ sender: Any) {
         
-        guard let newURL = NSURL(string: self.adsInfo.adsURLLink) else {
+        guard let string = self.adsInfo?.adsURLLink else {
             return
         }
+        
+        let newURL = NSURL(string: string)
 
-        NSWorkspace.shared.open(newURL as URL)
-
-        adDelegate?.kmAdViewClicked(self)
+        NSWorkspace.shared.open(newURL! as URL)
 
         if let completionHandler = self.completionHandler {
             completionHandler(currentPage + 1)
-            self.completionHandler = nil
         }
-        removeFromSuperview()
+        
+        adDelegate?.kmAdViewClicked(self)
     }
     
     @objc func buttonItemClicked_Close(_ sender: Any) {
@@ -307,7 +306,6 @@ class KMAdsWebView: NSView, WKNavigationDelegate, CAAnimationDelegate {
 
         if let completionHandler = self.completionHandler {
             completionHandler(0)
-            self.completionHandler = nil
         }
         removeFromSuperview()
     }

+ 7 - 6
PDF Office/PDF Master/Class/KMAdvertisement/Manager/KMAdvertisementManager.swift

@@ -98,6 +98,13 @@ extension KMAdvertisementManager {
                 if array != nil {
                     //解析数据
                     print("开始解析数据")
+                    for model in array as! [NSDictionary] {
+                        let jsonString: String = (model["detail"] as? String) ?? ""
+                        let jsonData: Data = jsonString.data(using: .utf8)!
+                        let dict = try?JSONSerialization.jsonObject(with: jsonData)
+                        infoDict = dict as! NSDictionary
+                    }
+                    
                     weakSelf.parseData(data: array as! [NSDictionary], isNeedLocalComparison: true) { data in
                         print("数据处理完毕")
                         if data.count != 0 {
@@ -105,12 +112,6 @@ extension KMAdvertisementManager {
                             completion(data.first, responseObject, nil)
                         }
                     }
-                    for model in array as! [NSDictionary] {
-                        let jsonString: String = (model["detail"] as? String) ?? ""
-                        let jsonData: Data = jsonString.data(using: .utf8)!
-                        let dict = try?JSONSerialization.jsonObject(with: jsonData)
-                        infoDict = dict as! NSDictionary
-                    }
                 } else {
                     print("解析数据失败array")
                     completion(nil, responseObject, error)

+ 1 - 1
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/KMAdsInfo.swift

@@ -11,7 +11,7 @@ import Cocoa
     
     public static let shareInstance = KMAdsInfoManager.init()
     
-    public var adsInfoArrM: NSMutableArray!
+    public var adsInfoArrM: NSMutableArray = NSMutableArray()
     
     override init() {
         super.init()