Home > Software engineering >  How to make custom CallBack button with void function in Swift
How to make custom CallBack button with void function in Swift

Time:11-22

I want to make a callback function with void function (()->()). But i still figure it how the actually void function work. There are two ViewController which one of them gonna used as bottomSheet in other controller. And I want to add callback Function when the bottomSheetInfo show up. Here's the code of bottom Sheet :

ViewController as Bottom Sheet Info `

import UIKit

class InfoSheeetViewController: UIViewController {
    
    @IBOutlet weak var tittleLabel: UILabel!
    @IBOutlet weak var messageLabel: UILabel!
    @IBOutlet weak var button: UIButton!
    @IBOutlet weak var iconView: UIImageView!
    
    var pageFrom: ScreenOrigin?
    var callbackActionPressed : (() -> Void)?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setData()
    }
    
    @IBAction func handleButtonActionPressed(_ sender: UIButton) {
        self.dismiss(animated: true, completion: nil)
        self.callbackActionPressed?()
    }

`

What must I do with another ViewController to make void function work ?. And if you don't mind, can you explain me how actually void function work in swift? Thank you so much

  • Related