In this iteration of the iOS Meetup, our experts from Seven Peaks Software will walk you through the Swift programming language, providing you with the most up-to-date tips and tricks for success in iOS development.
Rupendra Limbore, our first speaker who specializes in Tech Lead and has 12 years of experience in developing iOS apps related to finance, medical, and e-commerce domains, will kick off the meetup by discussing Concurrency in Swift.
Concurrency allows programs to handle multiple tasks at the same time. However, writing a concurrent program is not as simple as it appears. Dealing with threads and locks can be time-consuming, making concurrent programming difficult.
His topic will focus on making it as simple and understandable as possible so that any intermediate to advanced Swift developer can apply these concepts to their projects.
The second speaker, Saravudh (Tul) Sinsomros, is a Senior iOS developer with an innovative tech mind and 10+ years of experience developing iOS apps in the finance and e-commerce domains.
In addition, he possesses prior experience as a backend developer, managing databases, and networking systems.
Subjects and Operators in RxSwift will be covered in depth. RxSwift is a well-known library for creating asynchronous and event-driven programs with observable sequences. Subject and operation are fundamentals of RxSwift.
His topic will help you understand the mechanism and behavior of subjects, as well as the main combination operators in RxSwift. It is beneficial to begin by learning the fundamentals.
Finally, Ruttanachai (Pop) Auitragool -A senior iOS developer with 8 years of experience in e-commerce, video streaming, entertainment, and large-scale enterprise applications- will demonstrate how to improve your app’s performance.
He is passionate about simplifying code, streamlining development processes, and providing excellent user experiences.
You will understand the tools, metrics, and paradigms that can help to smooth your development process and contribute to a better user experience for your app. Because app performance is critical for user engagement and retention.
When an app grows in size, more features are added, and the app’s external dependencies grow. It is critical to assess the impact of these changes and to constantly improve the app for better performance.
Using candy as an example, demonstrate the two approaches with the goal of reaching a total of six candies in a bowl. The simplest method is to take one piece of candy at a time and drop it into another bowl, which requires six steps.
The second method involves grabbing two pieces of candy at a time and dropping them into a bowl, resulting in only three moves.
There are a few advantages of concurrency and the reason we need it.
Using candy as an example, demonstrate the two approaches with the goal of reaching a total of six candies in a bowl. The simplest method is to take one piece of candy at a time and drop it into another bowl, which requires six steps.
A base class that gives us the ability to deal with and manipulate the thread available on the operating system. This third class is defined and declared in the foundation framework.
So while using it, we need to import a foundation framework. Thread is available for our iOS 2.0 and onwards.
This is a very basic class and it can be used with an initializer passing prob to it or we can surpass the third class and implement the main method to it.
A preference for timely execution of a strategy.
This third priority varies between zero to one, the revolt value is point five. While Apple documentation clearly states that this value is just a guideline.
This value does not make sure that the priority that we have provided will be obeyed by the operating system because the priority of execution of a thread is decided by an operating system on a colonel level.
So, this value whatever we said is the guideline to an operating system to ask a priority for our threat.
How can we implement a simple set?
A scenario wherein we need to upload an image to the server. The four stages that you must complete are as follows:
When doing so, you must first define four different classes with the responsibility for each state. Now, this course just contains some, it is not implemented for full functionality, just for the general purpose. They implement our functionality but they don’t care about the threads, the currency, or the background processing.
The problem here is that whenever we call these functions directly from our view controller or view model. They will start on the main thread and the main thread is always utilized for UI updates.
Once we start calling these methods, the UI will get blocked. That’s why we need to call this method background today. These causes were implemented without considering the current currency.
Manage and implement different classes to handle concurrency. Now, looking at this fair map that has been implemented. It will take care of the action performing process as well as give us a call back from a caller function.
A callback can be a piece of code that will get carved once the feature or functionality or block of code has been executed. So once your asynchronous task is done, it is your responsibility to call the callback and give the caller the information that you’re done with the task.
Now, the callback may be simply void, it won’t take any details and it can also give us some results that can be utilized in a calorie function. For this, we use a research email.
What does it do? If we are fetching an image, the result will be expected as an image. In case an error occurs, this email helps us keep track of it.
This is the implementation, a very complex one as it is called callback hell.
If we have multiple steps in performing our code, we will get to have something with the invitation and a block inside a block which is referred to as callback hell.
Next is a crucial stage, the color thread. Color thread is something on which a function is getting caught. Many people make the mistake of calling a callback from a queue or from a thread on which it is getting executed.
What happens if you are running something in the background and you are calling a callback on the background thread, your collar function might be from a view controller which can still be caught on the background track.
If you are updating any UI in that, your application will crash because you are updating a UI from a background trend. Which should not be the case.
A base class that gives us the ability to deal with and manipulate the thread available on the operating system. This third class is defined and declared in the foundation framework.
There are three types based on creation access:
There are three types based on creation access:
Quality of Service (QoS)
We have to consider that the background priority or the background QOS will be used when we have a task that might chant for a few minutes to hours. It’s like indexing, we have to gather some major data from our system in storage.
The interesting thing about the GCD and operation queue is that there will always be a callback.
This is more advanced than GCD, how?
It provides you the functions like counseling, it provides dependency handling and it is easier and more object-oriented to implement.
For the operation queue, we have an operating cost. Operation cost is an upside cost. Apple had provided us to contribute classes with the implementation. They have blog operation and invocation operation. We can also surpass the operation cost on our own and implement a method main.
Once all the dependencies are met for an operation, the operation will start executing. This is a simple occurrence for implementation of the operation.
It takes the block in the initializer and the other class that we can implement when we have to override the main method. Initialize the operation class, add it to the operation tube and we are done. Operation Queue is available on iOS 2.0 and onwards.
When we start an operation there is something called a state of an operation that is defined and available as a seat of the operation changes. The four states are:
These are four important steps in an operation queue.
Implemented in Swift. It is available from iOS30 and Swift 5.5. The async-await features give us the ability to implement, and structure concurrency (the two keywords). The same keyword can also be implemented with the triumph cash. The rate parameter will be available for any of the methods as usual.
Advantages: