admin
2022-09-04 fa05f89529e05078b29606e4beda3de5cfdce485
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
//  CSJScriptMessageHandler.h
//  CSJAdSDK
//
//  Created by bytedance on 2020/5/28.
//  Copyright © 2020 bytedance. All rights reserved.
//
 
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
// https://www.jianshu.com/p/6ba2507445e4
// 原有的引用关系
// selfVC 强引用 WKWebView 强引用WKWebViewConfiguration 强引用WKUserContentController 强引用scriptMessageHandler(self) 导致循环引用
// 修改后的引用关系
// selfVC 强引用 WKWebView 强引用WKWebViewConfiguration 强引用WKUserContentController 强引用scriptMessageHandler(KSAdScriptMessageHandler)弱引用scriptMessageHandler(self) 打破循环引用
NS_ASSUME_NONNULL_BEGIN
 
@interface CSJScriptMessageHandler : NSObject <WKScriptMessageHandler>
 
@property (nonatomic, weak) id<WKScriptMessageHandler> realScriptMessageHandler;
 
- (id)initWithHandler:(id<WKScriptMessageHandler>)handle;
 
@end
 
NS_ASSUME_NONNULL_END