File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
LEEAlertSwiftDemo/LEEAlertSwiftDemo Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 29
29
#define DEFAULTBORDERWIDTH (1 .0f / [[UIScreen mainScreen ] scale ] + 0 .02f )
30
30
#define VIEWSAFEAREAINSETS (view ) ({UIEdgeInsets i; if (@available (iOS 11.0 , *)) {i = view.safeAreaInsets ;} else {i = UIEdgeInsetsZero;} i;})
31
31
32
+ NS_INLINE void lee_cleanupFunc (__strong dispatch_block_t *block) {
33
+ (*block)();
34
+ }
35
+
32
36
#pragma mark - ===================配置模型===================
33
37
34
38
typedef NS_ENUM (NSInteger , LEEBackgroundStyle) {
@@ -4048,13 +4052,18 @@ - (nonnull instancetype)init
4048
4052
4049
4053
self.isShowing = NO ;
4050
4054
4051
- __weak typeof (self) weakSelf = self;
4055
+ __block typeof (self) strongSelf = self;
4052
4056
4053
4057
self.config .modelFinishConfig = ^{
4054
4058
4055
- __strong typeof (weakSelf) strongSelf = weakSelf;
4059
+ __attribute__ ((cleanup (lee_cleanupFunc), unused)) __auto_type x = ^{
4060
+ // break circular reference after leaving the scope.
4061
+ strongSelf = nil ;
4062
+ };
4056
4063
4057
- if (!strongSelf) return ;
4064
+ if (!strongSelf) {
4065
+ return ;
4066
+ }
4058
4067
4059
4068
if ([LEEAlert shareManager ].queueArray .count ) {
4060
4069
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class ViewController: UIViewController {
18
18
super. touchesBegan ( touches, with: event)
19
19
20
20
let alert = LEEAlert . alert ( )
21
- _ = alert . config
21
+ . config
22
22
. leeTitle ( " 标题 " )
23
23
. leeContent ( " 内容 " )
24
24
. leeAction ( " 确认 " , {
You can’t perform that action at this time.
0 commit comments