https://dribbble.com/shots/1074099-Array/attachments/1074099-Array?mode=media

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.


https://dribbble.com/shots/3645975/attachments/3645975-Conference-Calling-App?mode=media

Have you ever face challenges in searching and sorting grouped data? If your answer is

  • Yes — No, worries we will learn a better way to handle it in this article.
  • No — That’s good, You might learn something.

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

Getting a…

Pratik Sodha

Software developer at Spaceo Technologies. Loves to create iOS apps. Github : https://github.com/Pratik-Sodha

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store