Swift ViewModel Memory Leak?

class VC1 :UIViewController() {  let viewModel = VC1ViewModel()  func callVC2(){     let vc2 = UIViewController()     vc2.onTap = { (value) in         self.viewModel.callMom()  }  deinit(){
print("VC1 dead")
}
}
func callVC2(){    let vc2 = UIViewController()    vc2.onTap = { [weak self] (value) in        self?.viewModel.callMom()}

--

--

--

Major in physical education. Football referee. And high interest in looking the world through the numbers.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

macOS App, 4. General layout

How to change Tab Bar or Navigation Title View font in Swift UI

Swift 5 Add A Lottie?

a-summary-of-how-why-and-what-we-do — SwiftERM

How to use SplitView SwiftUI

iOS — AppRouter -DeepLinking, Push Notifications, User State Preservence

Simplify API Calls in Swift

Dog with stick in mouth

Automate framework generation for a modular iOS project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mario tsai

Mario tsai

Major in physical education. Football referee. And high interest in looking the world through the numbers.

More from Medium

[Codility] PassingCars (Swift)

Bubble Sort in Swift

5 Tips when getting started with gRPC and iOS

Should we write unit tests for network classes?