A Subject is both an Observable (emits sequences) and an Observer (Subscriber). You can subscribe to a subject such that the subject acts as an Observable emitting values and also modify the subject.
Types of Subjects
BehaviorRelay, PublishSubject, ReplaySubject, AsyncSubject.
Note: Here we are going to talk about…
In this example the VStack on line 9 has two Views a Text and a Button.
On tapping the button, the action closure on line 13 toggles the State variable showSheetPresented…
Solve the problem of code duplication. Generics can be used to create a Generic data structure like Stack or Queues. Generics can also be used to create Generic functions.
Q: Examples of Generic in Swift Standard Library
Generic Data Structure
Examples of two generic data structures (Queue and Stack). Here Element is the placeholder type and Queue<Element> and Stack<Element> — the angled brackets tell the compiler that Element is only a place holder inside the function body and function definition. The actual type of Element is determined only at runtime.
Usage of Generic Stack and Generic Queue
iOS provides two ways to achieve multitasking
2. Grand Central Dispatch (GCD)
GCD Grand Central Dispatch
What is a DispatchQueue?
As the name suggests it is a queue (i.e. First-In-First-Out FIFO). You submit a block of code (closure) or an…
Pascal’s Triangle as known to the western world but I would like to refer it as Meru-prastaar — coming from the vedic land India or Khayyam triangle if you happen to hail from Persia. Nevertheless, it is an interesting arrangement of numbers :)
One of the solutions to print the…
A way to access the property, method, subscript of an optional in a safe way.
An alternative to “Forced Unwrapping” of an optional.
Use a question mark ? after the name of an optional and then access the property, method, or subscript of that optional.
Swift tip #1 Empower the print function using literal expressions
you can use literal expressions to print function names using
#function, lines numbers
#line and filenames