In Cocoa (and other frameworks that derive from NeXTSTEP), dealloc is the instance method responsible for tearing down an object. It should release the object's references to its ivars and then call up to the superclass's implementation.
Questions tagged [dealloc]
497 questions
6
votes
1 answer
Rare crash during dealloc AVCaptureVideoPreviewLayer
On client phones rarely can be replicated crash during camera dealloc
Fatal Exception: NSRangeException
Cannot remove an observer for the key path "changeSeed" from because it is not…

Igor Palaguta
- 3,579
- 2
- 20
- 32
6
votes
3 answers
The correct way to declare, alloc, load, and dealloc an NSMutableArray
I declare my array in my *.h file:
@interface aViewController: UIViewController
{
NSMutableArray *anArray; // You will need to later change this many times.
}
@end
I alloc memory for it my *.m file:
-(void) viewDidLoad
{
anArray =…

Bonnie
- 219
- 1
- 4
- 12
6
votes
2 answers
An Objective-C message was sent to a deallocated object (zombie) at address: 0x75d52a0
I am relatively new to iOS development so appreciate your help in finding out the root cause for the error that I encountered.
I tried to debug the error using Instruments (i.e. Allocations-Zombie Profiler) but I could not make sense of the call…

user1881383
- 61
- 1
- 4
5
votes
6 answers
Very strange behaviour of dealloc - not getting called
I have tested my all viewControllers dealloc methods. And all of them getting called properly on calling popViewControllerAnimated.
But only 1 controller's dealloc method not getting called. I am not able to figure out the issue.
While pushing to…

Tariq
- 9,861
- 12
- 62
- 103
5
votes
3 answers
premature dealloc in ARC based app
I have a problem that seems to be a premature release of an in-use object in an ARC based app. I'm trying to create a folder on an FTP server. The relevant parts of code are below; i'll describe the problem first.
problem with the code is, that the…

m Jae
- 725
- 2
- 8
- 20
5
votes
2 answers
removeObserver:forKeyPath: in dealloc
If my instance is observing some property of another object, am I supposed to call removeObserver:forKeyPath: in dealloc?

cfischer
- 24,452
- 37
- 131
- 214
5
votes
4 answers
Can I call [self retain] within -dealloc? Or, how do I ensure dealloc happens on the main thread?
Here is my situation. It's complicated so bear with me.
I have a view class, let's call it MyView. It creates a loading indicator subview, and then starts a background operation that will load data. It also creates a block that the background queue…

easeout
- 8,665
- 5
- 43
- 51
5
votes
2 answers
NSKeyedArchiver.archivedData does not work in Swift 3 iOS
When try to encode my custom object in iOS swift get this error from Xcode 8.3
unrecognized selector sent to instance 0x60800166fe80
*** -[NSKeyedArchiver dealloc]: warning: NSKeyedArchiver deallocated without having had -finishEncoding called on…

reza_khalafi
- 6,230
- 7
- 56
- 82
5
votes
3 answers
key value observers were still registered with it when controller is deallocated
I added an observer in the code and then removed it in dealloc and viewWillDisappear but still i am getting an error stating
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x167e5980 of
…

Sudhanshu Gupta
- 2,255
- 3
- 36
- 74
5
votes
4 answers
Qt: What is the correct and safe way to write the destructor of this class?
I am using Qt5 on Windows7 and I recently found an interesting Qt example code.
Basically, it looks like this:
ButtonWidget::ButtonWidget(const QStringList &texts, QWidget * parent)
: QWidget(parent)
{
signalMapper = new…

סטנלי גרונן
- 2,917
- 23
- 46
- 68
5
votes
3 answers
Reduce the amount of time to release 1 million + objects while popping out VC
The current iOS app that we have has to download more than a million objects from the server and we keep it in an array for certain purposes. When the user is done with this functionality and the app takes a while to go back to the previous screen…

Vinny
- 227
- 2
- 10
5
votes
4 answers
Objective-C: Do you have to dealloc property objects before deallocating the parent object?
Let's say I have an object named "foo" with another object named "bar" as property.
When "foo" deallocates, will it automatically remove all references to "bar" so that "bar" deallocates as well? or will "foo" deallocate and "bar" float in memory…

Marnix v. R.
- 1,638
- 4
- 22
- 33
5
votes
3 answers
SKScene Fails to deallocate memory resulting in bounded memory growth
I have been struggling with this for days, for some reason my SKScenes are not deallocating correctly, this results in bounded memory growth as each time i exit and enter a scene the memory jumps up. This means after say 10 rounds of the game the…

SmokersCough
- 967
- 7
- 22
5
votes
2 answers
iOS - viewController dealloc method not called after popping to previous viewController
In iOS, I pop from current viewController into previous one, but it doesn't go into dealloc.
Is this because there is another pointer pointing towards the current viewController, either in a different viewController or in the current one?
This is…

Operative
- 149
- 1
- 2
- 10
5
votes
4 answers
UIViewController -dealloc method not called
I am working with Automatic Reference Counting.
I have a custom UIViewController subclass and whenever I call -presentViewController: animated:completion: or remove its view from the superview I would like to NSLog something like "I am dealloced"…

the_critic
- 12,720
- 19
- 67
- 115