Check for systemItem inside an UIBarButtonItem override

Hi,

I need to understand inside an override of UIBarButtonItem what is the systemItem of the button (done, add, trash, search, ...).

Unfortunately at the moment the only method I found is to inspect the content of self.description (see below), but this solution, as well as being ugly, is very fragile because we can't be sure that the description will be the same also on future version of iOS / Swift.

Someone know a better way to check for systemItem inside an UIBarButtonItem override class?

Thank you

class BarButtonItem: UIBarButtonItem {
    override func awakeFromNib() {
        super.awakeFromNib()
        print(self.description)
    }
}
<MyApp.BarButtonItem: 0x7fadbcacbea0> systemItem=Trash

Here is how to set it

https://stackoverflow.com/questions/62080863/programattically-set-barbutton-system-item

Hope that helps to find how to get it.

Or could you compare self.image with the different system images(clear, done…).

Doc is really sparse on this.

Maybe you can use:

self.buttonGroup?.barButtonItems[index].style.rawValue

with index for the button in the bar.

There is a systemItem enum

case done
The system Done button, localized. 
case cancel
The system Cancel button, localized. 
case edit
The system Edit button, localized. 
case save
The system Save button, localized. 
case add
The system plus button containing an icon of a plus sign. 
case flexibleSpace
Blank space to add between other items. The space is distributed equally between the other items. Other item properties are ignored when this value is set.
case fixedSpace
Blank space to add between other items. Only the width property is used when this value is set.
case compose
The system compose button. 
case reply
The system reply button. 
case action
The system action button. 
case organize
The system organize button. 
case bookmarks
The system bookmarks button. 
case search
The system search button. 
case refresh
The system refresh button. 
case stop
The system stop button. 
case camera
The system camera button. 
case trash
The system trash button. 
case play
The system play button. 
case pause
The system pause button. 
case rewind
The system rewind button. 
case fastForward
The system fast forward button. 
case undo
The system undo button. 
case redo
The system redo button. 
case pageCurl
The system page curl button. 
Deprecated
case close
The system close button.
Check for systemItem inside an UIBarButtonItem override
 
 
Q