[1] Singleton When a class is restricted to just one instantiation, that one object is called a singleton. A singleton class returns the same instance no matter how many times an application requests it. Example : + (instancetype)sharedManager { static DocumentManager * sharedDocumentManager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ sharedDocumentManager = [[DocumentManager alloc] init]; NSLog(@"Singleton memory address: %@", sharedDocumentManager); }); return sharedDocumentManager; } [2] Abstract Factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Creates a base class with abstract methods defining methods for the objects that should be created. Each factory class w...
Recently I published a countdown app . At one point of development - I have to show a timer on a UILabel which ticks on each seconds. As usual I started setting text to a label object - self .timerLabel.text = someString Easy piece of cake right !? But wait ... it won't take much user attention when timer ticks on every seconds. So I decided to make use of a simple animation while label gets text update. I found there are dozens of ways to animate a label. In this short article, I listed 3 best way you can animate text on a label. ( Spoiler Alert 👀- I decided to go with 3rd option) 1. Fade In - Fade out animation : CATransition class has got transition type `fade`. With timing function of CATransition - I was able to see the below result. let animation: CATransition = CATransition () animation.timingFunction = CAMediaTimingFunction (name: CAMediaTimingFunctionName .easeInEaseOut) animation.type = CATransitionType .fade animation.subtype = C...