I have a bunch of UIBarButtonItem
s in a UIToolbar
. Each of which has its SystemItem
set in Storyboard, so that they'll look like system icons.
I'd rather not make an IBAction
for each and every one of them, so I need some way to differentiate them in a switch statement. I am assuming the best way to do this is by looking at their SystemItem
, since that's the only property that makes them unique from one another.
Here's what I've got so far:
@IBAction func buttonPressed(_ sender: UIBarButtonItem) {
let controller = UIImagePickerController()
controller.delegate = self
switch sender.[WHAT DO I PUT HERE?] {
case .compose:
controller.sourceType = .photoLibrary
case .camera:
controller.sourceType = .camera
default:
break
}
present(controller, animated: true)
}
If there is a better way to differentiate between UIBarButtonItem
s, I'm all ears.