You may have asked yourself “why either the conforming types must define initializers of protocols as ‘required’ or they must be final”.
We cannot define designated initializers in extensions. But why is that? In this post I am going to show you an example of the reason of that.
In Swift, generic protocols can only be used as a generic constraint. But why is that? Why we can’t use them as normal protocols?
You probably have seen the date and time of the messages in the Messages app and other messagings that are relative to the current date and time. This post will explain how to calculate the relative date and time with Swift.
In WWDC2019, Apple introduced Diffable Data Source as a new approach for providing data for table view and collection views. Apple’s video was explained using an interesting sample project. This article shows how to use diffable data source with clean architecture in mind. To do so, I apply clean architecture to the WiFi settings part of Apple´s sample project of WWDC19.
Probably the NSFetchedResutlsController makes the tightest coupling between UI and another layers of an iOS application. NSFetchedResutlsController Class has been created by Apple to provide a seamless data flow from Core Data layer to UIKit and vice a versa. The MVC is Apple’s native architecture and NSFetchedResultsController lays in the Model layer of this architecture perfectly but it cannot provide features like unit testing, low coupling, and independency. You might say that the lack of these possibilities is due to the MVC’s nature. I would answer yes, but these features are very important for having a well-structured application that is readable, testable, maintainable, and extendable. So if you value these traits, you do not have any problems with having some more small files in your project and you love Clean Architecture, keep on reading this article.
Sometimes it is really necessary to know the device lock state especially when we are working with background services like Bluetooth or networking. Actually, iOS API does not let developers check if the device is locked or unlocked programmatically. But there is a workaround that lets us find it out with some seconds of delay after locking.
It is easy to change the background color of the selected cell in a table view. Each UITableViewCell has a selectedBackgroundView which is shown when the cell is selected. This view should be set programmatically and it’s better to do that in a UITableViewCell custom class.
Without any doubt, Swift is the main programming language for developing new applications for Apple developers, but there are many apps on the App store that have been developed using Objective-C. Many of these apps are serving millions of users worldwide. So to build your career, you probably need to be able to read or even write Objective-C codes.
Based on the memory handling methods, types in Swift are divided into two different categories: value types and reference types. There are some basic differences between value and reference types which causes them to behave differently in the same conditions. So developers should know their specifications to write logical codes both during working with Apple’s predefined types and during defining their own custom types.