iOS: Preventing a singleton from being deallocated when the app is in the background.
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