File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public final class Flex {
3131 /**
3232 Flex items's UIView.
3333 */
34- public let view : UIView
34+ private weak var view : UIView ?
3535 private let yoga : YGLayout
3636
3737 /**
@@ -73,8 +73,12 @@ public final class Flex {
7373 */
7474 @discardableResult
7575 public func addItem( _ view: UIView ) -> Flex {
76- self . view. addSubview ( view)
77- return view. flex
76+ if let host = self . view {
77+ host. addSubview ( view)
78+ return view. flex
79+ } else {
80+ preconditionFailure ( " Trying to modify deallocated host view " )
81+ }
7882 }
7983
8084 /**
@@ -954,8 +958,12 @@ public final class Flex {
954958 */
955959 @discardableResult
956960 public func backgroundColor( _ color: UIColor ) -> Flex {
957- view. backgroundColor = color
958- return self
961+ if let host = self . view {
962+ host. backgroundColor = color
963+ return self
964+ } else {
965+ preconditionFailure ( " Trying to modify deallocated host view " )
966+ }
959967 }
960968
961969 // MARK: Enums
You can’t perform that action at this time.
0 commit comments