• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
iOS: Preventing a singleton from being deallocated when the app is in the background.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iOS: Preventing a singleton from being deallocated when the app is in the background.


  • Subject: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • From: Alex Zavatone <email@hidden>
  • Date: Wed, 19 Oct 2016 13:41:44 -0500

We are running into what appears to be a case where a singleton that has been created through GCD dispatch_once may be getting deallocated by the OS.

To check and see if this is the case, I have put logging code in the dealloc method, but our logs do show the init method being called twice even though the method is past the dispatch_once.

I'm interested in seeing if I can prevent the singleton from being deallocated.

I have seen on discussion where people suggest keeping a private strong property in the singleton with a reference to self to prevent this from happening.

Something like
    self.selfReference = self;

within an interface extension.

Naturally, this is raising some eyebrows with other members of the team, but currently, no one has a solution to make sure that this core singleton doesn't get deallocated when the app is in the background and has been running for a while.

Does this sound sane or a horrible idea?

If it does sound like a horrible idea, how would you suggest preventing an important singleton from being deallocated?

Thanks in advance,
Alex Zavatone
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
      • From: Jens Alfke <email@hidden>
    • Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
      • From: Steve Christensen <email@hidden>
  • Prev by Date: Re: observeValueForKeyPath:... called too often in macOS 12
  • Next by Date: Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • Previous by thread: Re: inconsistencies in view renderings
  • Next by thread: Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • Index(es):
    • Date
    • Thread