Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized selector #12

Open
alamodey opened this issue Apr 3, 2022 · 0 comments
Open

Unrecognized selector #12

alamodey opened this issue Apr 3, 2022 · 0 comments

Comments

@alamodey
Copy link

alamodey commented Apr 3, 2022

import UIKit
import Toolbar

class ViewController: UIViewController {
  
  lazy var toolbar: Toolbar = {
    let toolbar: Toolbar = Toolbar([
      Toolbar.Item(title: "BUTTON", target: nil, action: #selector(test(_:))),
      Toolbar.Item(title: "BUTTON", target: nil, action: nil),
      Toolbar.Item(title: "BUTTON", target: nil, action: nil)
    ])
    return toolbar
  }()
  
  
  override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = .systemBackground
    self.view.addSubview(self.toolbar)
  }
  
  @objc func test(_ sender: Any) {
    print("hello")
  }
}

Why does the first button crash:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull test:]: unrecognized selector sent to instance 0x1de715eb0'
terminating with uncaught exception of type NSException
CoreSimulator 802.6 - Device: iPhone 13 mini (41207433-2958-4380-93E0-D0448B566794) - Runtime: iOS 15.4 (19E240) - DeviceType: iPhone 13 mini
(lldb)

Can you update your demo to show the buttons working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant