'How to pass value to selector func in swift?

I have a UIButton called textButton and I have value session which I need to pass to selector method to hide the button in SessionClass.

 public init(session: SessionClass?) {
    if let session = session {
         session.sessionDelegate = self
    }
    textButton = UIButton(type: .custom)
    textButton.addTarget(self, action: #selector(didPressButton(sender:)), for: .touchUpInside)
    self.addSubview(textButton)
 }
    


@objc private func didPressButton(sender: UIButton) {
   let sessionCustom = sender.sessionCustom  //Crash here: Thread 1: EXC_BAD_ACCESS (code=2, address=0x12f0242c0)
   sessionCustom?.spikeButton.isHidden = true
   layoutIfNeeded()
}

class CustomButton : UIButton {
   var sessionCustom: SessionClass?

   convenience init(sessionCustom: SessionClass, object: Any) {
        self.init()
        self.sessionCustom = sessionCustom
    }
}

Session class:

@objc public class SessionClass: UIView {
   public var spikeButton = UIButton()

   func layoutView() {
      spikeButton.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
      spikeButton.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
      addSubview(spikeButton)
   }
}

After subclassing UIButton and passing the value app crashes- Thread 1: EXC_BAD_ACCESS (code=2, address=0x12f0242c0)



Solution 1:[1]

GitHub Pages provides only static sites. That is, a GitHub Pages site can contain only HTML, CSS, JavaScript and the like that are delivered without changes to the web browser. Like with all static site hosts, there is no backend server to perform operations on behalf of the user, including running executables of any sort, so that isn't possible here.

This is the case because GitHub does not want to run arbitrary code on behalf of users when rendering pages (which is a sensible approach in terms of security). Even if GitHub did support that, GitHub uses Linux, so exe files would be right out.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bk2204