1

I am trying to figure out which better approach using Swift language, which is better to use and when to use each one?

1-

class CartManager {
    static let shared = CartManager()
    func addToCart() {
    }
}

2-

class CartManager {
    static func addToCart() {
    }
}
  • Read these three https://stackoverflow.com/questions/519520/difference-between-static-class-and-singleton-pattern – mahan Mar 23 '21 at 13:02
  • https://stackoverflow.com/questions/3532161/what-is-the-difference-between-a-singleton-pattern-and-a-static-class-in-java – mahan Mar 23 '21 at 13:03
  • https://stackoverflow.com/questions/3714971/difference-between-singleton-class-and-static-class – mahan Mar 23 '21 at 13:03

0 Answers0