Skip to content

Instantly share code, notes, and snippets.

@byJeevan
Created May 13, 2026 12:36
Show Gist options
  • Select an option

  • Save byJeevan/323558c07c82f3cb50989e196ad27ddc to your computer and use it in GitHub Desktop.

Select an option

Save byJeevan/323558c07c82f3cb50989e196ad27ddc to your computer and use it in GitHub Desktop.
iOS Pro Notes - 2

Notes 13-May-2026

@jeevan2628

jeevan2628 commented May 13, 2026

Copy link
Copy Markdown

How optionals implemented under the hood ?
Working of Retain count ?
Higher order functions compactMap, reduce etc ?
Copy on write concept
class vs Actor vs MainActor , re- entrancy problem ?


let vs var
class vs struct
mutable vs immutable
Any vs AnyObject
@escaping and non-escaping
Array vs Array slice vs collection of one

@byJeevan

Copy link
Copy Markdown
Author

Pagination: Cursor vs Offset based.

@jeevan2628

jeevan2628 commented May 18, 2026

Copy link
Copy Markdown

SOLID Principle [p0]

The SOLID principles are 5 design principles used to write clean, maintainable, and scalable code.

  1. S — Single Responsibility Principle (SRP)
    A class should have only one reason to change.
    → One class = one responsibility.

  2. O — Open/Closed Principle (OCP)
    Code should be open for extension but closed for modification.
    → Add new behavior without changing existing code.

  3. L — Liskov Substitution Principle (LSP)
    Subclasses should be replaceable for their parent classes without breaking behavior.
    → Child class must behave correctly as parent.

  4. I — Interface Segregation Principle (ISP)
    Don’t force classes to implement methods they don’t need.
    → Create small, specific interfaces.

  5. D — Dependency Inversion Principle (DIP)
    Depend on abstractions, not concrete implementations.
    → Use protocols/interfaces instead of direct class dependency.

Simple iOS Example

Instead of:

class NetworkManager {
    func fetch() {}
}

Prefer:

protocol Networking {
    func fetch()
}

class NetworkManager: Networking {
    func fetch() {}
}

class HomeViewModel {
    let network: Networking
    init(network: Networking) {
        self.network = network
    }
}

This follows DIP and improves testing & flexibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment