Interview guides / ios
God settings controller: iOS Interview Question
God settings controller interview question with a clear example answer for iOS engineers. Practice with AceMobileInterview.
This is a common iOS interview topic: God settings controller.
Below is a concise answer you can adapt in a real interview, then go deeper in the full AceMobileInterview track.
1.SettingsViewController does networking, parsing, disk I/O, and UI—and embeds an API key. Refactor the worst smells (≈45–60 min).
## Scenario Classic “temporary” VC that absorbed every concern. ## How to investigate - Skim `SettingsViewController.swift` size and responsibilities - Grep for `api_key` / `sk_live` / secrets - Note `Data.write` on the button action (main thread) ## Planted bug 1: Hardcoded API key **Symptom:** Secret in source control **Root cause:** `let apiKey = "sk_live_..."` in the VC **Fix:** Move to xcconfig / info plist placeholder / env; never commit real keys; use a stub in the exercise ## Planted bug 2: God object **Symptom:** Untestable blob **Root cause:** URLSession + JSONDecoder + UserDefaults + UI in one type **Fix:** Extract `SettingsRepository` (load/save remote+local); VC becomes binder ## Planted bug 3: Main-thread disk write **Symptom:** Brief hitch on Save **Root cause:** Synchronous `data.write(to:)` on main **Fix:** Background write; atomic replace; main-thread success toast only ## Optimization tips - Interview bar is “extract boundaries,” not a perfect architecture diagram - Call out how you’d add unit tests around the repository ## What to say in the interview - How you prioritized secret removal first - What you left as intentional stretch
Keep going with AceMobileInterview
Reading helps. Timed practice locks it in. Jump into the interactive track for algorithms with LeetCode links, studio projects, debugging zips, and mobile system design.