UISlider valueChanged has uninitialized UIEvent

This issue was in the first iOS 26 beta and it still there with Xcode 26 beta 6 (17A5305f). Feedback is FB18581605 and contains sample project to reproduce the issue.

I assign a target and action to a UISlider for the UIControl.Event.valueChanged value:

addTarget(self, action: #selector(sliderValueDidChange), for: .valueChanged)

Here’s the function.

@objc
func sliderValueDidChange(_ sender: UISlider, event: UIEvent) {
    print(event)
}

When printing the event value, there is a crash. When checking the event value with lldb, it appears uninitialized.

Thanks for filling the bug report.

Update your function signature to

 slider.addTarget(self, action: #selector(sliderValueDidChange(_:for:)), for: .valueChanged)

and the method to

  @objc
    private func sliderValueDidChange(_ sender: UISlider, for event: UIEvent) {
        print("Slider value changed to: \(sender.value)")
        print("Event: \(event)")
    }

See Responding to control-based events using target-action for examples on defining action methods you use to respond to events

Thanks for taking the time to answer. It's still crashing with your recommendation (screenshot 2) and lldb still shows an uninitialized pointer (screenshot 1).

Also, I should add that this starts crashing with iOS 26 betas. It has been working fine with every iOS version so far.

.

Effectively, your code crashes in Xcode 26 / iOS 26 (but works in Xcode 16.4 / iOS 18.4).

I think problem is the type used for event.

I changed UIEvent in sliderValueDidChange:

@objc func sliderValueDidChange(_ sender: UISlider, for event: UIEvent) {

to UIControl.Event

@objc func sliderValueDidChange(_ sender: UISlider, for event: UIControl.Event) {
    print("Slider value changed to: \(sender.value) ")
    print(event)
}

No more crash, just the log:

Slider value changed to: 0.025641026 
UIControlEvents(rawValue: 0)
Slider value changed to: 0.03926282 
UIControlEvents(rawValue: 0)

Did Xcode 26 replaced UIEvent by UIControl.Event ? In that case I could not find it in documentation.

That's at least a documentation bug (or an error compiler should detect).

I note the modified code also works with Xcode 16.4 / iOS 18.4, but givesa different UIControlEvents value

Slider value changed to: 0.00042842288 
UIControlEvents(rawValue: 105553178306624)
Slider value changed to: 0.0038560412 
UIControlEvents(rawValue: 105553178306624)

So, yes, I think it is worth a bug report, because many of us will face the issue.

Let's wait for DTS engineer analysis, in case. Then close the thread.

[@Bigby Woody](https://developer.apple.com/forums/profile/Bigby Woody) Could you please test the code snippet I’ve provided in Xcode beta 6 and iOS 26 beta 7? I’d like to know if you’re still able to reproduce the runtime exception.

@DTS Engineer unfortunately yes. I reproduced with Xcode 26 beta 6 (17A5305f) and an iPad running iOS 26 beta 7 (23A5326a).

The following code will produce the runtime exception.

 slider.addTarget(
  self, 
  action: #selector(sliderValueDidChange(_:for:)), 
  for: .valueChanged
)
// ...
@objc
func sliderValueDidChange(_ sender: UISlider, for event: UIEvent) {
  print(event)
}

whereas changing the event parameter type to UIControl.Event doesn't produce it:

@objc
func sliderValueDidChange(_ sender: UISlider, for event: UIControl.Event) {
  print(event)
}

Do note that changing the action method body to


@objc
func sliderValueDidChange(_ sender: UISlider, for event: UIEvent) {
  print("Event: \(event)")
}

has always been working fine, but that is because the String interpolation treats the event value as nil I believe (by printing an empty String).

So the question is: did the required signature for selector change in Xcode 26 ? I have noticed the same issue for other types of control.

UISlider valueChanged has uninitialized UIEvent
 
 
Q