Objc Slider looks cool but crashes


ChatGPT 4 helped me get this slider appearing on screen, but it crashes when I slide it:

-- Define an objc block for handling slider events
SliderValueHandler = objc.class("SliderValueHandler")
function SliderValueHandler:sliderValueChanged(objcArgs)
    -- Handle slider value changes here
    local value = slider:value_()
    print("Slider value:", objcArgs)
handler = SliderValueHandler()

-- Create a UISlider instance
local UIScreen = objc.UIScreen
local UIScreen_mainScreen = UIScreen:mainScreen()
local UIScreen_mainScreen_bounds = objc.viewer.view.bounds
local sliderWidth = 200
local sliderHeight = 50

local UISlider = objc.UISlider
local slider = objc.UISlider()
slider.frame = objc.rect(sliderWidth, sliderHeight, UIScreen_mainScreen_bounds.size.width / 2 - sliderWidth / 2, objc.viewer.view.bounds.size.height - sliderHeight - 20)

-- Set slider properties


-- Add target for slider value changes
slider:addTarget_action_forControlEvents_(objc.viewer.view, objc.selector("sliderValueChanged"), objc.enum.UIControlEvents.valueChanged)

-- Add the slider to the main view

I got this working in my ColorCritters project, which is on another thread.

Out of curiosity, what was the issue?

I think I had a colon or_ out of place or something.