Skip to content

Commit

Permalink
Develop disable iboutlet trailing closure (#3)
Browse files Browse the repository at this point in the history
* Unpublish iboutlet with trailing closures. Use ibsubiews instead

* desactivate iboutlet variants with trailing ibsubview closures due to possible missuage in edge cases
  • Loading branch information
Adobels authored Oct 5, 2023
1 parent 9581a5d commit 0c158b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 48 deletions.
42 changes: 0 additions & 42 deletions Sources/UIViewKit/UIViewDSL+IBOutlet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,9 @@ extension UIViewDSL where Self: UIView {
return self
}

@discardableResult
public func ibOutlet(_ outlet: inout Self?, @UIViewBuilder _ content: () -> [UIView]) -> Self {
outlet = self
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}

@discardableResult
public func ibOutlet(_ outlet: inout Self?, @UIViewBuilder _ content: (UIView) -> [UIView]) -> Self {
outlet = self
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}

@discardableResult
public func ibOutlet(_ outlet: inout Self, @UIViewBuilder _ content: () -> [UIView]) -> Self {
outlet = self
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}

@discardableResult
public func ibOutlet(_ outlet: inout Self, @UIViewBuilder _ content: (UIView) -> [UIView]) -> Self {
outlet = self
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}

@discardableResult
public func ibOutlet(in outlet: inout [Self]) -> Self {
outlet.append(self)
return self
}

@discardableResult
public func ibOutlet(in outlet: inout [Self], @UIViewBuilder _ content: () -> [UIView]) -> Self {
outlet.append(self)
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}

@discardableResult
public func ibOutlet(in outlet: inout [Self], @UIViewBuilder _ content: (UIView) -> [UIView]) -> Self {
outlet.append(self)
UIViewDSLEngine.shared.addSubviews(content, to: self)
return self
}
}
12 changes: 6 additions & 6 deletions Tests/UIViewKitTests/IBOutletTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IBOutletTests: XCTestCase {

var view = UIView()

let newView = UIView().ibOutlet(&view) {
let newView = UIView().ibOutlet(&view).ibSubviews {
UIView()
}

Expand All @@ -51,7 +51,7 @@ class IBOutletTests: XCTestCase {

var view = UIView()

let newView = UIView().ibOutlet(&view) { _ in
let newView = UIView().ibOutlet(&view).ibSubviews { _ in
UIView()
}

Expand All @@ -61,7 +61,7 @@ class IBOutletTests: XCTestCase {
func testIBOutletInWithTrailingClosureOfIbSubviews() throws {
var views: [UIView] = []

let newView = UIView().ibOutlet(in: &views) {
let newView = UIView().ibOutlet(in: &views).ibSubviews {
UIView()
}

Expand All @@ -72,7 +72,7 @@ class IBOutletTests: XCTestCase {
func testIBOutletInWithTrailingClosureOfIbSubviewsAndSuperview() throws {
var views: [UIView] = []

let newView = UIView().ibOutlet(in: &views) { _ in
let newView = UIView().ibOutlet(in: &views).ibSubviews { _ in
UIView()
}

Expand All @@ -83,7 +83,7 @@ class IBOutletTests: XCTestCase {
func testIBOutletWithForceUnwrapWithTrailingClosureOfIbSubviews() async throws {
var view: UIView!

let newView = UIView().ibOutlet(&view) {
let newView = UIView().ibOutlet(&view).ibSubviews {
UIView()
}

Expand All @@ -93,7 +93,7 @@ class IBOutletTests: XCTestCase {
func testIBOutletWithForceUnwrapWithTrailingClosureOfIbSubviewsAndSuperview() async throws {
var view: UIView!

let newView = UIView().ibOutlet(&view) { _ in
let newView = UIView().ibOutlet(&view).ibSubviews { _ in
UIView()
}

Expand Down

0 comments on commit 0c158b8

Please sign in to comment.