How to use UIControl class

Best Mockingbird code snippet using UIControl

RPDraggableButton.swift

Source:RPDraggableButton.swift Github

copy

Full Screen

...59 self.setTitle(self.titleLabel?.text?.capitalized, for: .normal)60 61 self.layer.backgroundColor = UIColor.gray.cgColor62 63 // addTarget(self, action: #selector(touchDragEnter(control:event:)), for: UIControlEvents.touchDragEnter)64 // addTarget(self, action: #selector(touchDragInside(control:event:)), for: UIControlEvents.touchDragInside)65 // addTarget(self, action: #selector(touchDragOutside(control:event:)), for: UIControlEvents.touchDragOutside)66 // addTarget(self, action: #selector(touchDragExit(control:event:)), for: UIControlEvents.touchDragExit)67 // addTarget(self, action: #selector(touchUpOutside(control:event:)), for: UIControlEvents.touchUpOutside)68 // addTarget(self, action: #selector(touchDown(control:event:)), for: UIControlEvents.touchDown)69 // addTarget(self, action: #selector(touchCancel(control:event:)), for: UIControlEvents.touchCancel)70 // addTarget(self, action: #selector(touchDownRepeat(control:event:)), for: UIControlEvents.touchDownRepeat)71 // addTarget(self, action: #selector(editingDidBegin(control:event:)), for: UIControlEvents.editingDidBegin)72 // addTarget(self, action: #selector(editingChanged(control:event:)), for: UIControlEvents.editingChanged)73 // addTarget(self, action: #selector(editingDidEnd(control:event:)), for: UIControlEvents.editingDidEnd)74 // addTarget(self, action: #selector(editingDidEndOnExit(control:event:)), for: UIControlEvents.editingDidEndOnExit)75 // addTarget(self, action: #selector(valueChanged(control:event:)), for: UIControlEvents.valueChanged)76 77 addTarget(self, action: #selector(drag(control:event:)),78 for: [UIControl.Event.touchDragInside,79 UIControl.Event.touchDragExit,80 UIControl.Event.touchDragOutside])81 82 addTarget(self, action: #selector(touchUpInside(control:event:)), for: UIControl.Event.touchUpInside)83 84 }85 86 var isDraged: Bool = false87 88 89 90 @objc func drag(control: UIControl, event: UIEvent) {91 92 isDraged = true93 94 if let center = event.allTouches?.first?.location(in: self.superview) {95 control.center = center96 }97 98 maxX = (self.superview?.frame.width)! - 199 maxY = (self.superview?.frame.height)! - 1100 101 if ((self.frame.origin.x + btnHalfWd) > maxX) {102 control.center.x = (maxX - btnHalfWd)103 }104 if ((self.frame.origin.x - btnHalfWd) < minX) {105 control.center.x = (minX + btnHalfWd);106 }107 if ((self.frame.origin.y + btnHalfHt) > maxY) {108 control.center.y = (maxY - btnHalfHt)109 }110 if (self.frame.origin.y - btnHalfHt < minY) {111 control.center.y = (minY + btnHalfHt);112 }113 }114 115 @objc func touchUpInside(control: UIControl, event: UIEvent) {116 117 if isDraged {118 isDraged = false119 }else{120 customDraggableButtonProtocol?.onClick()121 }122 }123 124 // func touchDragEnter(control: UIControl, event: UIEvent) { print("touchDragEnter") }125 // func touchDragOutside(control: UIControl, event: UIEvent) { print("touchDragOutside") }126 // func touchDragExit(control: UIControl, event: UIEvent) { print("touchDragExit") }127 // func touchUpOutside(control: UIControl, event: UIEvent) { print("touchUpOutside") }128 // func touchDown(control: UIControl, event: UIEvent) { print("touchDown") }129 // func touchCancel(control: UIControl, event: UIEvent) { print("touchCancel") }130 // func touchDownRepeat(control: UIControl, event: UIEvent) { print("touchDownRepeat") }131 // func editingDidBegin(control: UIControl, event: UIEvent) { print("editingDidBegin") }132 // func editingChanged(control: UIControl, event: UIEvent) { print("editingChanged") }133 // func editingDidEnd(control: UIControl, event: UIEvent) { print("editingDidEnd") }134 // func editingDidEndOnExit(control: UIControl, event: UIEvent) { print("editingDidEndOnExit") }135 // func valueChanged(control: UIControl, event: UIEvent) { print("valueChanged") }136 137}...

Full Screen

Full Screen

UIControl+Actions.swift

Source:UIControl+Actions.swift Github

copy

Full Screen

1//2// UIControl+Actions.swift3// AirPay4//5// Created by KD Chen on 28/8/17.6// Copyright © 2017 Quest Payment Systems Pty Ltd. All rights reserved.7//8import UIKit9import ObjectiveC10typealias PTControlBlock = () -> Void11extension UIControl {12 // The extension provides shortcut functions for addTarget() method to all UIControl based components13 14 // MARK: Public15 @discardableResult func bind(_ block: @escaping PTControlBlock, for event: UIControlEvents) -> UIControl {16 self.add(block, for: event)17 return self18 }19 @discardableResult func unBind(for event: UIControlEvents) -> UIControl {20 self.remove(for: event)21 return self22 }23 // MARK: Private24 fileprivate func add(_ block: @escaping PTControlBlock, for event: UIControlEvents) {25 guard let action = self.action(for: event) else {26 return27 }28 var s = self.EventsBlocks29 s[event.rawValue] = block30 self.EventsBlocks = s31 self.addTarget(self, action: action, for: event)32 }33 fileprivate func remove(for event: UIControlEvents) {34 guard let action = self.action(for: event) else {35 return36 }37 var s = self.EventsBlocks38 s.removeValue(forKey: event.rawValue)39 self.EventsBlocks = s40 self.removeTarget(self, action: action, for: event)41 }42 fileprivate static var eventsBlocksKey = "eventsBlocksKey"43 fileprivate var EventsBlocks: [AnyHashable:Any] {44 get {45 guard let s = objc_getAssociatedObject(self, &UIControl.eventsBlocksKey) else {46 let result = [AnyHashable: Any]()47 objc_setAssociatedObject(self, &UIControl.eventsBlocksKey, result, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)48 return result49 }50 return s as! [AnyHashable : Any]51 }52 set {53 objc_setAssociatedObject(self, &UIControl.eventsBlocksKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)54 }55 }56 fileprivate func action(for event: UIControlEvents) -> Selector? {57 switch event {58 case UIControlEvents.touchDown: return #selector(touchDown)59 case UIControlEvents.touchDownRepeat: return #selector(touchDownRepeat)60 case UIControlEvents.touchUpInside: return #selector(touchUpInside)61 case UIControlEvents.touchUpOutside: return #selector(touchUpOutside)62 case UIControlEvents.touchCancel: return #selector(touchCancel)63 case UIControlEvents.valueChanged: return #selector(valueChanged)64 case UIControlEvents.editingDidBegin: return #selector(editingDidBegin)65 case UIControlEvents.editingChanged: return #selector(editingChanged)66 case UIControlEvents.editingDidEnd: return #selector(editingDidEnd)67 case UIControlEvents.editingDidEndOnExit: return #selector(editingDidEndOnExit)68 default: return .none69 }70 }71 @objc fileprivate func touchDown() {72 if let block = EventsBlocks[UIControlEvents.touchDown.rawValue] as? PTControlBlock {73 block()74 }75 }76 @objc fileprivate func touchDownRepeat() {77 if let block = EventsBlocks[UIControlEvents.touchDownRepeat.rawValue] as? PTControlBlock {78 block()79 }80 }81 @objc fileprivate func touchUpInside() {82 if let block = EventsBlocks[UIControlEvents.touchUpInside.rawValue] as? PTControlBlock {83 block()84 }85 }86 @objc fileprivate func touchUpOutside() {87 if let block = EventsBlocks[UIControlEvents.touchUpOutside.rawValue] as? PTControlBlock {88 block()89 }90 }91 @objc fileprivate func touchCancel() {92 if let block = EventsBlocks[UIControlEvents.touchCancel.rawValue] as? PTControlBlock {93 block()94 }95 }96 @objc fileprivate func valueChanged() {97 if let block = EventsBlocks[UIControlEvents.valueChanged.rawValue] as? PTControlBlock {98 block()99 }100 }101 @objc fileprivate func editingDidBegin() {102 if let block = EventsBlocks[UIControlEvents.editingDidBegin.rawValue] as? PTControlBlock {103 block()104 }105 }106 @objc fileprivate func editingChanged() {107 if let block = EventsBlocks[UIControlEvents.editingChanged.rawValue] as? PTControlBlock {108 block()109 }110 }111 @objc fileprivate func editingDidEnd() {112 if let block = EventsBlocks[UIControlEvents.editingDidEnd.rawValue] as? PTControlBlock {113 block()114 }115 }116 @objc fileprivate func editingDidEndOnExit() {117 if let block = EventsBlocks[UIControlEvents.editingDidEndOnExit.rawValue] as? PTControlBlock {118 block()119 }120 }121}...

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2import Mockingbird3class ViewController: UIViewController {4 override func viewDidLoad() {5 super.viewDidLoad()6 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)7 }8 @objc func buttonTapped() {9 }10}11import UIKit12import Mockingbird13class ViewController: UIViewController {14 override func viewDidLoad() {15 super.viewDidLoad()16 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)17 }18 @objc func buttonTapped() {19 }20}21import UIKit22import Mockingbird23class ViewController: UIViewController {24 override func viewDidLoad() {25 super.viewDidLoad()26 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)27 }28 @objc func buttonTapped() {29 }30}31import UIKit32import Mockingbird33class ViewController: UIViewController {34 override func viewDidLoad() {35 super.viewDidLoad()36 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)37 }38 @objc func buttonTapped() {39 }40}41import UIKit42import Mockingbird43class ViewController: UIViewController {44 override func viewDidLoad() {45 super.viewDidLoad()46 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)47 }48 @objc func buttonTapped() {49 }50}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1let button = UIButton()2button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)3let button = UIButton()4button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)5let button = UIButton()6button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)7let button = UIButton()8button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)9import UIKit10class CustomView: UIView {11 override init(frame: CGRect) {12 super.init(frame: frame)13 setup()14 }15 required init?(coder aDecoder: NSCoder) {16 super.init(coder: aDecoder)17 setup()18 }19 func setup() {20 view = loadViewFromNib()21 addSubview(view)22 }23 func loadViewFromNib() -> UIView {24 let bundle = Bundle(for: type(of: self))25 let nib = UINib(nibName: nibName, bundle: bundle)26 let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView27 }28 func setLabel(text: String) {29 }30}31import UIKit32class ViewController: UIViewController {33 override func viewDidLoad() {34 super.viewDidLoad()35 let customView = CustomView()

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2class ViewController: UIViewController {3 override func viewDidLoad() {4 super.viewDidLoad()5 let button = UIButton()6 button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)7 button.addTarget(self, action: #selector(buttonAction), for: .touchDown)8 }9 @objc func buttonAction() {10 print("Button tapped")11 }12}13import MockingbirdFramework14class ControlMock: UIControl {15 var mock: Mock<ControlMock> = Mock()16 override func addTarget(_ target: Any?, action: Selector, for controlEvents: UIControl.Event) {17 mock.call("addTarget(_:action:for:)", args: target, action, controlEvents)18 }19}20import XCTest21@testable import MockingbirdFramework22@testable import MockingbirdSample23class ControlMockTests: XCTestCase {24 func test_addTarget() {25 let button = ControlMock()26 let target = NSObject()27 let action = #selector(buttonAction)28 button.addTarget(target, action: action, for: .touchUpInside)29 button.mock.verify("addTarget(_:action:for:)", args: target, action, .touchUpInside)30 }31}32import MockingbirdFramework33protocol ProtocolMock {34 func testFunction()35}36class ProtocolMockMock: ProtocolMock {37 var mock: Mock<ProtocolMockMock> = Mock()38 func testFunction() {39 mock.call("testFunction")40 }41}42import MockingbirdFramework43import UIKit

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import Mockingbird2import UIKit3import Mockingbird4import UIKit5class MyViewController: UIViewController {6 let button = UIButton()7 override func viewDidLoad() {8 super.viewDidLoad()9 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)10 }11 @objc func buttonTapped() {12 print("Tapped!")13 }14}15import Mockingbird16import UIKit17class MyViewController: UIViewController {18 let button = UIButton()19 override func viewDidLoad() {20 super.viewDidLoad()21 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)22 }23 @objc func buttonTapped() {24 print("Tapped!")25 }26}27import Mockingbird28import UIKit29class MyViewController: UIViewController {30 let button = UIButton()31 override func viewDidLoad() {32 super.viewDidLoad()33 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)34 }35 @objc func buttonTapped() {36 print("Tapped!")37 }38}39import Mockingbird40import UIKit41class MyViewController: UIViewController {42 let button = UIButton()43 override func viewDidLoad() {44 super.viewDidLoad()45 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)46 }47 @objc func buttonTapped() {48 print("Tapped!")49 }50}51import Mockingbird52import UIKit53class MyViewController: UIViewController {54 let button = UIButton()55 override func viewDidLoad() {56 super.viewDidLoad()57 button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)58 }59 @objc func buttonTapped() {60 print("Tapped!")61 }62}63import Mockingbird64import UIKit65class MyViewController: UIViewController {66 let button = UIButton()67 override func viewDidLoad() {68 super.viewDidLoad()69 button.addTarget(self, action: #selector(buttonTapped), for

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import Mockingbird2import UIKit3class ViewController: UIViewController {4 @IBAction func buttonPressed(_ sender: Any) {5 }6}7import Mockingbird8import UIKit9class ViewController: UIViewController {10 @IBAction func buttonPressed(_ sender: Any) {11 }12}13import Mockingbird14import UIKit15class ViewController: UIViewController {16 @IBAction func buttonPressed(_ sender: Any) {17 }18}19import Mockingbird20import UIKit21class ViewController: UIViewController {22 @IBAction func buttonPressed(_ sender: Any) {23 }24}25import Mockingbird26import UIKit27class ViewController: UIViewController {28 @IBAction func buttonPressed(_ sender: Any) {29 }30}31import Mockingbird32import UIKit33class ViewController: UIViewController {34 @IBAction func buttonPressed(_ sender: Any) {35 }36}37import Mockingbird38import UIKit39class ViewController: UIViewController {40 @IBAction func buttonPressed(_ sender: Any) {41 }42}43import

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2class ViewController: UIViewController {3 override func viewDidLoad() {4 super.viewDidLoad()5 button.addTarget(self, action: #selector(ViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)6 }7 func buttonTapped(sender: UIButton) {8 print("button tapped")9 }10}11import UIKit12class MockViewController: UIViewController {13 override func viewDidLoad() {14 super.viewDidLoad()15 button.addTarget(self, action: #selector(MockViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)16 }17 func buttonTapped(sender: UIButton) {18 print("button tapped")19 }20}21import UIKit22class MockButton: UIButton {23}24import UIKit25class MockUIControl: UIControl {26}27import UIKit28class MockUIView: UIView {29}30import UIKit31class MockUIResponder: UIResponder {32}33Hi @jamesonquave, this issue should be fixed in the latest version of Mockingbird CLI (0.9.0). Please let me know if you run into any other problems. Thanks again for the report!

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1class A: UIControl {2 override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {3 super.sendAction(action, to: target, for: event)4 }5 override func sendActions(for controlEvents: UIControlEvents) {6 super.sendActions(for: controlEvents)7 }8}9class B {10 func foo() {11 let a = A()12 a.sendAction(#selector(B.foo), to: nil, for: nil)13 a.sendActions(for: .touchUpInside)14 }15}16class A: UIControl {17 override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {18 super.sendAction(action, to: target, for: event)19 }20 override func sendActions(for controlEvents: UIControlEvents) {21 super.sendActions(for: controlEvents)22 }23}24class B {25 func foo() {26 let a = A()27 a.sendAction(#selector(B.foo), to: nil, for: nil)28 a.sendActions(for: .touchUpInside)29 }30}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2import Mockingbird3class ViewController: UIViewController {4 override func viewDidLoad() {5 super.viewDidLoad()6 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)7 }8 @objc func targetMethod() {9 print("targetMethod")10 }11}12import UIKit13import Mockingbird14class ViewController: UIViewController {15 override func viewDidLoad() {16 super.viewDidLoad()17 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)18 }19 @objc func targetMethod() {20 print("targetMethod")21 }22}23import UIKit24import Mockingbird25class ViewController: UIViewController {26 override func viewDidLoad() {27 super.viewDidLoad()28 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)29 }30 @objc func targetMethod() {31 print("targetMethod")32 }33}34import UIKit35import Mockingbird36class ViewController: UIViewController {37 override func viewDidLoad() {38 super.viewDidLoad()39 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)40 }41 @objc func targetMethod() {42 print("targetMethod")43 }44}45import UIKit46import Mockingbird47class ViewController: UIViewController {48 override func viewDidLoad() {49 super.viewDidLoad()50 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)51 }52 @objc func targetMethod() {53 print("targetMethod")54 }55}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import Mockingbird2import UIKit3class MyButton: UIControl {}4let button = MyButton()5button.addTarget(self, action: #selector(MyButton.action), for: .touchUpInside)6button.sendActions(for: .touchUpInside)7 a.sendActions(for: .touchUpInside)8 }9}10class A: UIControl {11 override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {12 super.sendAction(action, to: target, for: event)13 }14 override func sendActions(for controlEvents: UIControlEvents) {15 super.sendActions(for: controlEvents)16 }17}18class B {19 func foo() {20 let a = A()21 a.sendAction(#selector(B.foo), to: nil, for: nil)22 a.sendActions(for: .touchUpInside)23 }24}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2import Mockingbird3class ViewController: UIViewController {4 override func viewDidLoad() {5 super.viewDidLoad()6 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)7 }8 @objc func targetMethod() {9 print("targetMethod")10 }11}12import UIKit13import Mockingbird14class ViewController: UIViewController {15 override func viewDidLoad() {16 super.viewDidLoad()17 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)18 }19 @objc func targetMethod() {20 print("targetMethod")21 }22}23import UIKit24import Mockingbird25class ViewController: UIViewController {26 override func viewDidLoad() {27 super.viewDidLoad()28 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)29 }30 @objc func targetMethod() {31 print("targetMethod")32 }33}34import UIKit35import Mockingbird36class ViewController: UIViewController {37 override func viewDidLoad() {38 super.viewDidLoad()39 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)40 }41 @objc func targetMethod() {42 print("targetMethod")43 }44}45import UIKit46import Mockingbird47class ViewController: UIViewController {48 override func viewDidLoad() {49 super.viewDidLoad()50 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)51 }52 @objc func targetMethod() {53 print("targetMethod")54 }55}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import Mockingbird2import UIKit3class MyButton: UIControl {}4let button = MyButton()5button.addTarget(self, action: #selector(MyButton.action), for: .touchUpInside)6button.sendActions(for: .touchUpInside)7}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2import Mockingbird3class ViewController: UIViewController {4 override func viewDidLoad() {5 super.viewDidLoad()6 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)7 }8 @objc func targetMethod() {9 print("targetMethod")10 }11}12import UIKit13import Mockingbird14class ViewController: UIViewController {15 override func viewDidLoad() {16 super.viewDidLoad()17 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)18 }19 @objc func targetMethod() {20 print("targetMethod")21 }22}23import UIKit24import Mockingbird25class ViewController: UIViewController {26 override func viewDidLoad() {27 super.viewDidLoad()28 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)29 }30 @objc func targetMethod() {31 print("targetMethod")32 }33}34import UIKit35import Mockingbird36class ViewController: UIViewController {37 override func viewDidLoad() {38 super.viewDidLoad()39 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)40 }41 @objc func targetMethod() {42 print("targetMethod")43 }44}45import UIKit46import Mockingbird47class ViewController: UIViewController {48 override func viewDidLoad() {49 super.viewDidLoad()50 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)51 }52 @objc func targetMethod() {53 print("targetMethod")54 }55}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1class A: UIControl {2 override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {3 super.sendAction(action, to: target, for: event)4 }5 override func sendActions(for controlEvents: UIControlEvents) {6 super.sendActions(for: controlEvents)7 }8}9class B {10 func foo() {11 let a = A()12 a.sendAction(#selector(B.foo), to: nil, for: nil)13 a.sendActions(for: .touchUpInside)14 }15}16class A: UIControl {17 override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {18 super.sendAction(action, to: target, for: event)19 }20 override func sendActions(for controlEvents: UIControlEvents) {21 super.sendActions(for: controlEvents)22 }23}24class B {25 func foo() {26 let a = A()27 a.sendAction(#selector(B.foo), to: nil, for: nil)28 a.sendActions(for: .touchUpInside)29 }30}

Full Screen

Full Screen

UIControl

Using AI Code Generation

copy

Full Screen

1import UIKit2import Mockingbird3class ViewController: UIViewController {4 override func viewDidLoad() {5 super.viewDidLoad()6 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)7 }8 @objc func targetMethod() {9 print("targetMethod")10 }11}12import UIKit13import Mockingbird14class ViewController: UIViewController {15 override func viewDidLoad() {16 super.viewDidLoad()17 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)18 }19 @objc func targetMethod() {20 print("targetMethod")21 }22}23import UIKit24import Mockingbird25class ViewController: UIViewController {26 override func viewDidLoad() {27 super.viewDidLoad()28 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)29 }30 @objc func targetMethod() {31 print("targetMethod")32 }33}34import UIKit35import Mockingbird36class ViewController: UIViewController {37 override func viewDidLoad() {38 super.viewDidLoad()39 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)40 }41 @objc func targetMethod() {42 print("targetMethod")43 }44}45import UIKit46import Mockingbird47class ViewController: UIViewController {48 override func viewDidLoad() {49 super.viewDidLoad()50 mock.addTarget(self, action: #selector(targetMethod), for: .touchUpInside)51 }52 @objc func targetMethod() {53 print("targetMethod")54 }55}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockingbird automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful