Adding a click event to a UIView
is something that is required most of the time. For views like UIButton
, we can connect an IBAction
with the event type and detect the click events but sometimes we need it for Lable or even other views.
This particular script will help you to implement a Click listener to all UIView and its subclasses in a clean way.
…As we all know, Classes are reference type whereas Structures and Enumerations are of a value type in swift. What does that mean is that a class object shares a single instance of the object and passes the same reference if passed to any function or new object whereas the value type is the one which creates a copy of it and passes only the value.
…Recently, while working with swift I came up with a use case where I need to modify the variable passed as an argument to a function. Eventually, all the variables passed to a function are of an immutable type which cannot be changed which is similar to a let variable. If it’s a class object, you cannot create a new object but you can manipulate the properties of that class object or you can call any function with that object.
…Object creation is a heavy process. When we create a class object, all the public and private properties of that class are initialised inside the constructor. Every variable inside a class initialisation requires a certain amount of time to allocate the memory on the heap and hold its reference on the stack. The more variables, the more time it may take but since the time is in microseconds or even less, it’s not observable.
…It is a very common use case where we want to return two values from a method, can be either of same data type or can be of different data types.
…