discardableResult

This commit is contained in:
xaoxuu 2022-09-19 20:43:42 +08:00
parent 7e6c87364e
commit b62c027cd5
3 changed files with 5 additions and 5 deletions

View File

@ -13,7 +13,7 @@ extension Alert: InternalConvenienceLayout {
@discardableResult public func add(action: Action) -> Button { @discardableResult public func add(action: Action) -> Button {
insert(action: action, at: actionStack.arrangedSubviews.count) insert(action: action, at: actionStack.arrangedSubviews.count)
} }
public func insert(action: Action, at index: Int) -> Button { @discardableResult public func insert(action: Action, at index: Int) -> Button {
let btn = Button(config: config, action: action) let btn = Button(config: config, action: action)
if index < actionStack.arrangedSubviews.count { if index < actionStack.arrangedSubviews.count {
actionStack.insertArrangedSubview(btn, at: index) actionStack.insertArrangedSubview(btn, at: index)
@ -106,7 +106,7 @@ extension Alert: InternalConvenienceLayout {
// MARK: // MARK:
public func set(customView: UIView) -> UIView { @discardableResult public func set(customView: UIView) -> UIView {
self.customView = customView self.customView = customView
contentView.subviews.forEach({ $0.removeFromSuperview() }) contentView.subviews.forEach({ $0.removeFromSuperview() })
contentView.addSubview(customView) contentView.addSubview(customView)

View File

@ -13,7 +13,7 @@ extension Sheet: ConvenienceLayout {
@discardableResult public func add(action: Action) -> Button { @discardableResult public func add(action: Action) -> Button {
insert(action: action, at: contentStack.arrangedSubviews.count) insert(action: action, at: contentStack.arrangedSubviews.count)
} }
public func insert(action: Action, at index: Int) -> Button { @discardableResult public func insert(action: Action, at index: Int) -> Button {
let btn = SheetButton(config: config, action: action) let btn = SheetButton(config: config, action: action)
if index < contentStack.arrangedSubviews.count { if index < contentStack.arrangedSubviews.count {
contentStack.insertArrangedSubview(btn, at: index) contentStack.insertArrangedSubview(btn, at: index)
@ -102,7 +102,7 @@ extension Sheet: ConvenienceLayout {
// MARK: // MARK:
public func set(customView: UIView) -> UIView { @discardableResult public func set(customView: UIView) -> UIView {
self.customView = customView self.customView = customView
contentView.addSubview(customView) contentView.addSubview(customView)
return customView return customView

View File

@ -21,7 +21,7 @@ public extension Toast {
insert(action: action, at: actionStack.arrangedSubviews.count) insert(action: action, at: actionStack.arrangedSubviews.count)
} }
func insert(action: Action, at index: Int) -> Button { @discardableResult func insert(action: Action, at index: Int) -> Button {
let btn = ToastButton(config: config, action: action) let btn = ToastButton(config: config, action: action)
if index < actionStack.arrangedSubviews.count { if index < actionStack.arrangedSubviews.count {
actionStack.insertArrangedSubview(btn, at: index) actionStack.insertArrangedSubview(btn, at: index)