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

How to mess up your SwiftUI project and ruin your lifecycle

Swift playgrounds for UX designers

The “My Playgrounds” screen on iPad

How to unlock the app using Touch ID and Face ID in Swift.

How to show image and text in menu item in SwiftUI for macOS

What exactly mean by Copy on Write in Swift ?

Get your iOS App Store Reviews in Slack with the Slack RSS Integration

How to Name Mocks in Mockito 3

What is Comparable Protocol in Swift

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

Singly Linked Lists in Swift

Developing twitter splash screen for iOS application

AppDelegate Lifecycle 🥚🐣🐥🐓

TDD with CoreBluetooth