@@ -42,22 +42,22 @@ class MyMandelbrotView : UIView {
42
42
private func configuredPipeline( ) -> AnyCancellable {
43
43
let pipeline = self . trigger
44
44
. receive ( on: DispatchQueue . main)
45
- . map { ( ) -> ( CGPoint , CGRect ) in
45
+ . map { [ unowned self ] ( ) -> ( CGPoint , CGRect ) in
46
46
print ( " start on main " )
47
47
let center = CGPoint ( x: self . bounds. midX, y: self . bounds. midY)
48
48
let bounds = self . bounds
49
49
return ( center: center, bounds: bounds)
50
50
}
51
51
. receive ( on: draw_queue)
52
- . map { ( center, bounds) -> CGContext in
52
+ . map { [ unowned self ] ( center, bounds) -> CGContext in
53
53
print ( " background start " )
54
54
let bitmap = self . makeBitmapContext ( size: bounds. size)
55
55
self . draw ( center: center, bounds: bounds, zoom: 1 , context: bitmap)
56
56
print ( " background end " )
57
57
return bitmap
58
58
}
59
59
. receive ( on: DispatchQueue . main)
60
- . map { ( bitmap: CGContext ) -> ( ) in
60
+ . map { [ unowned self ] ( bitmap: CGContext ) -> ( ) in
61
61
print ( " main again " )
62
62
self . bitmapContext = bitmap
63
63
self . setNeedsDisplay ( )
@@ -67,20 +67,23 @@ class MyMandelbrotView : UIView {
67
67
}
68
68
69
69
private func configuredPipeline2( ) -> AnyCancellable {
70
- let p1 = switchTo ( upstream: self . trigger, on: DispatchQueue . main) { ( ) -> ( CGPoint , CGRect ) in
70
+ let p1 = switchTo ( upstream: self . trigger, on: DispatchQueue . main) {
71
+ [ unowned self] ( ) -> ( CGPoint , CGRect ) in
71
72
print ( " start on main " )
72
73
let center = CGPoint ( x: self . bounds. midX, y: self . bounds. midY)
73
74
let bounds = self . bounds
74
75
return ( center: center, bounds: bounds)
75
76
}
76
- let p2 = switchTo ( upstream: p1, on: draw_queue) { ( center, bounds) -> CGContext in
77
+ let p2 = switchTo ( upstream: p1, on: draw_queue) {
78
+ [ unowned self] ( center, bounds) -> CGContext in
77
79
print ( " background start " )
78
80
let bitmap = self . makeBitmapContext ( size: bounds. size)
79
81
self . draw ( center: center, bounds: bounds, zoom: 1 , context: bitmap)
80
82
print ( " background end " )
81
83
return bitmap
82
84
}
83
- let p3 = switchTo ( upstream: p2, on: DispatchQueue . main) { ( bitmap: CGContext ) -> ( ) in
85
+ let p3 = switchTo ( upstream: p2, on: DispatchQueue . main) {
86
+ [ unowned self] ( bitmap: CGContext ) -> ( ) in
84
87
print ( " main again " )
85
88
self . bitmapContext = bitmap
86
89
self . setNeedsDisplay ( )
@@ -90,20 +93,23 @@ class MyMandelbrotView : UIView {
90
93
91
94
private func configuredPipeline3( ) -> AnyCancellable {
92
95
self . trigger
93
- . performOn ( DispatchQueue . main) { ( ) -> ( CGPoint , CGRect ) in
96
+ . performOn ( DispatchQueue . main) {
97
+ [ unowned self] ( ) -> ( CGPoint , CGRect ) in
94
98
print ( " start on main " )
95
99
let center = CGPoint ( x: self . bounds. midX, y: self . bounds. midY)
96
100
let bounds = self . bounds
97
101
return ( center: center, bounds: bounds)
98
102
}
99
- . performOn ( draw_queue) { ( center, bounds) -> CGContext in
103
+ . performOn ( draw_queue) {
104
+ [ unowned self] ( center, bounds) -> CGContext in
100
105
print ( " background start " )
101
106
let bitmap = self . makeBitmapContext ( size: bounds. size)
102
107
self . draw ( center: center, bounds: bounds, zoom: 1 , context: bitmap)
103
108
print ( " background end " )
104
109
return bitmap
105
110
}
106
- . performOn ( DispatchQueue . main) { ( bitmap: CGContext ) -> ( ) in
111
+ . performOn ( DispatchQueue . main) {
112
+ [ unowned self] ( bitmap: CGContext ) -> ( ) in
107
113
print ( " main again " )
108
114
self . bitmapContext = bitmap
109
115
self . setNeedsDisplay ( )
0 commit comments