Simple app that show feed with questions from StackOverflow, using Stack Exchange API

I’ve Used the MVVM design pattern because I think it’s a much better design than MVC, where we get huge controllers with too much responsibility.
I think that Controllers should be simple and dumb as possible.
In the code you will be able to see i kept all logic in the view models + i’m always thinking how can I decouple my viewmodels as much as possible from each other.
In order to achieve decoupling I used: dependency injection, delegates and completion closure.

To fetch Data I used, in the app user can choose through Segment controller if he want to see all questions regardless of their state (Answered / Unanswered),
only Answered questions and only questions with no answers. App will fetch the most recent questions.
I’ve created 3 different filter to achieve this:

All Questions filter – //!)riR7ZAnq.5)aew*O3KM&site=stackoverflow

I Used tableViewController.refreshControl to refresh the table. Users can refresh by swiping the table. (as on Instagram app)

Requests for the next page with new models will take place when the last cell of the table view will be displayed.

I’ve face two problems during building the App:

  1. Problem:
    In the Task I’ve been asked to filter with Answers/noAnswer but the api does not provide an endpoint for questions with answers (
    I’ve queried a filter for answers. When user click on specific question i’m building the link for the question from the model.question_id

  2. Problem:
    When app first launch when I tried to fetch data on viewDidLoad(), detching data taking to long and TableView show empty for 1-2 seconds until data is retrieve and table is refreshed
    From what I was taught and experienced Singletons are bad practice for most of the time.
    I usually tried to avoid them as much as possible.
    But, in this scenario i made the QuestionsManager a Singleton so i can init him and fetch the models for the first View user’s interact with, on the Success callback
    I changed the root window viewcontroller, then I passed to Datasource.setup() the StackOverflowQuestionsManager.shared as a “dependency injected”.
    However I would rather think of some better design than use a singleton here.
    So to conclude, in SceneDelegate I’m changing the window?.rootViewController to be the LaunchScreen and fetching first models (All questions as it by default the first screen)
    in the completion handler i’m changing the window?.rootViewController to be the rootviewcontroller of the main storyboard.
    That way I’m making sure the QuestionsManager singleton object has models to show when building table views.

    1. Problem:
      Load the WKWebView before showing the webview:
      I’ve added a UIActivityIndicatorView for better UX. Can be approved in my honest opinion.


View Github