Search code examples
iosswiftdebugginguislider

How to determine the identity of a UISlider assigned to a struct variable


I have a struct that stores the last three UISliders touched. These are defined in another class (my ViewController). Here's the struct:

struct lastSlider {
   var current: UISlider!
   var previous: UISlider!
   var previousprevious: UISlider!

   mutating func setCurrent(slider: UISlider) {
      if slider != current {
         //push into stack
         previousprevious = previous
         previous = current
         current = slider
   }
}

For debug purposes I want to be able to determine which UISliders are lastSlider.current etc. I have tried simply printing their .debugDescription but that only gives me information about them, not their name.

How do I identify a UISlider for debugging?


Solution

  • As @crizzis wrote:

    How about using tags? developer.apple.com/documentation/uikit/uiview/1622493-tag

    This solved my problem!