Browse Questions
- Use Fastlane's firebaseappdistribution plugin to build an Ad Hoc .ipa and upload it to Firebase — testers receive a download link by email within minutes.
- SOLID is a set of five design guidelines for maintainable OOP code: | Principle | Idea | Swift application | |--|--|--| | Single Responsibility | A type should have one reason to change | Split a…
- A retain cycle occurs when two objects hold strong references to each other, preventing ARC from deallocating either.
- Test coverage measures what percentage of your code is executed by tests.
Answer: A retain cycle occurs when two objects hold strong references to each other, preventing ARC from deallocating either. Memory leaks.
Common case — closure capturing self:
// ❌ Retain cycle — viewModel holds closure, closure holds viewModel
viewModel.onUpdate = {
self.updateUI() // strong capture
}
// ✅ Break cycle with [weak self]
viewModel.onUpdate = { [weak self] in
self?.updateUI()
}
// ✅ Or [unowned self] if self is guaranteed to outlive the closure
viewModel.onUpdate = { [unowned self] in
self.updateUI()
}
How to find them: Xcode's Memory Graph Debugger (Debug > Memory Graph) — look for objects that still exist after they should be deallocated.