In iOS it’s a simple thing to iterate an array and display data upon to view; It’s another thing to do something with sorting, filtering, or both together.
Let’s say we have some records and that are displayed over table view. And for the same table view have the feature to show data after sort and filter.
So, most of us doing some conditional work and manage some flags to manage our data source.
New way to handle an UIControl event using the completion block.
In iOS13 UIKit introduce UIAction to make sharing event handling code easier. Earlier UIAction usage limited as UIMenu element action closure.
From iOS14, Apple expands UIAction API for UIControl and UIBarButtonItem. UIControl comes up with new convenience init method which takes one action as a parameter. For BarButtonItem also available init method which accepts action.
//Initializer method of UIControlconvenience init(frame: CGRect, primaryAction: UIAction?)
primary action available for such controls which are inherited from UIControl. Like UIButton, UITextFiled, UISwitch, UIPageControl, UIStepper.
Let's dive into some code