#StackBounty: #object-oriented #design-patterns #swift Implement The Singleton Pattern for Persistency managers Swift

Bounty: 50

I am creating an iOS app and I want to implement Singleton Pattern.
I have created “Singleton” LibraryAPI to act as an entry point UserManager object to get data from web API. after that I used a facade Pattern “method” to call UserManager implementation.

final class LibraryAPI {

    static let shared  =  LibraryAPI()
    private let userManager  =  UsersManager()
    private let isOnline  =  false 

    private init(){

    }

    func getUsers() -> [User] {
        return userManager.getUsers()
    }
}

my questions:

  1. if I have another Manager Class like “album” class should I use the same LibraryAPI and it will become a monolithic class and how to avoid that?
  2. should I create a “Singleton” LibraryAPI class for each manager object like UserLibraryAPI and albumLibraryAPI?

Note: any references or articles are welcome 🙂


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.