iOS: Memory leaks and Notifications

Leaks

What this has to do with Notifications?

NotificationCenter.default.addObserver(self, selector: #selector(observerFired), name: NSNotification.Name(rawValue: “NotifFired”), object: nil)
deinit {
NotificationCenter.default.removeObserver(self)
}
  • Make sure delegates are marked weak
  • Self captured in closures, to be made weak or unowned ( not all self need that )
  • If a child object has a parent object as its property, try to use weak or unowned

Tools

GOAL : MAKE SURE deinit GETS CALLED

--

--

--

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

Recommended from Medium

Combining the Facebook API and web analytics: how does sharing correlate with reading?

Connecting to an AKS Cluster Non Interactivity — Part 1

It’s Not Just Code, It’s a Network

Free Udemy Course

GraphQL On HTTP + Avoiding Query Spam

Alibaba Cloud HBase X-Pack Service: A New Standard for HBase Cloud Services

Building An Automated Video Encoding Pipeline In AWS (Graviton 2, Batch and ECS)

Insights into Dukaan by KhataBook(Now MyStore)

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
anoop m

anoop m

More from Medium

ITMS-90165 error

ITMS-90165 error

Dependency Management in iOS

Adapter vs Wrapper

Handling Concurrency with Async Await in Swift