Skip to content

UIKit

Clean Architecture with NSFetchedResultsController

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.

iOS, How to check if the device is locked or unlocked programmatically

Check iPhone Lock State Programmatically

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.

UITableView Selected Cell Background Color

UITableView Selected Cell Background Color

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.