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]
496 questions
7
votes
3 answers
Xcode and ARC debugging issue (skipping dealloc)
I have spent some time debugging a weird issue with ARC and custom dealloc functions.
I'm subclassing NSOperation class
I set completion block for this operation
The operation is referenced by a strong property of very flat object (no methods,…
simpleone
- 290
- 2
- 10
7
votes
3 answers
autorelease vs. release in dealloc
I know memory management in iOS is tricky subject to newbies like me, but I was hoping for a clear explanation here on stackoverflow which I could not find anywhere else.
So, pretend I have a property / ivar
@property(nonatomic, retain)…
pille
- 1,381
- 1
- 13
- 18
7
votes
2 answers
What explains best the difference between [myVar dealloc] and [myVar release]?
I think I know the difference, but don't know how to explain that correctly.
dealloc removes the memory reserved by that variable totally and immediately.
release decrements the retain counter of that variable's memory by -1. if it was 1, then it's…
Thanks
- 39,247
- 69
- 202
- 315
7
votes
1 answer
Calling a method on self while in dealloc
I have a dictionary of objects that need to be cleaned up before they are released. I have a method that does this for the entire dictionary. Before I release the dictionary in my -dealloc method, I want to do the same thing. However, I am not…
Don
- 3,604
- 1
- 24
- 47
7
votes
1 answer
UIViewController & UIview dealloc not getting called
I have a Navigation based view controller and in the view controller i have hidden the top navigation bar and use a custom UIView as the navigation bar.
The UIView bar has a back button and I use Delegate methods(I have declared a protocol) to…
B K
- 1,534
- 2
- 18
- 38
7
votes
2 answers
Is it bad form to synchronize NSUserDefaults in -(void)dealloc?
I load from NSUserDefaults in my object's init method.
Can I save to NSUserDefaults in my object's dealloc method?
Something exactly like:
-(void)dealloc {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults…
Kenny Winker
- 11,513
- 7
- 50
- 77
7
votes
2 answers
Memory leak with UIWebView
My project is a hybrid static lib for showing a UIWebView with some JS to control the logic. When I use 64bit and run demo on iOS 8/iPhone 6, the memory keeps going to 30M or more!
When I use generation in instrument, the increased memory usage is…
shan li
- 73
- 1
- 4
7
votes
3 answers
Cocoa bindings and KVO, unregister the observer, when the observing object gets `dealloced`
How can i unregister the observer, when the observing object gets dealloced?
How can cocoa bindings handle a situation when the observed objects gets deallocated?
By using manual KVO, i have to remove the observing (removeObserver) before dealloc…
Peter Lapisu
- 18,394
- 14
- 107
- 163
7
votes
1 answer
NSInvocation with block arguments
I'm trying to pass block arguments to a NSInvocation, but the app crashes. The invocation makes a network request and calls the success or failure blocks. I think the problem is that blocks are dealloced before the network request finishes. I…
pshah
- 1,954
- 1
- 19
- 39
6
votes
4 answers
Vector as a class member
Hello I have this question:
I would like to have a vector as class member. This is perhaps my question
easier for you and I apologize for that.
how should I declare the vector? And is this correct? std::vector *myVector; or std::vector…
Safari
- 9,810
- 20
- 76
- 158
6
votes
4 answers
why compiler is defering std::list deallocation?
I have the following code to test memory deallocation using a std::list container:
#include
#include
-
#include
Nelstaar
- 721
- 9
- 25
6
votes
2 answers
can we override alloc and dealloc in objective C?
I know that this is rarely required to override the alloc or dealloc methods,but if required is it possible in iPhone programming?
User97693321
- 3,348
- 7
- 43
- 69
6
votes
2 answers
Objective-C releasing a property declared in a category?
I have a category on an existing class that adds a property and a few methods to the class.
@interface AClass (ACategory) {
NSString *aProperty;
}
@property (nonatomic, retain) NSString *aProperty;
@end
In the implementation file, I want to…
Anurag
- 132,806
- 34
- 214
- 257
6
votes
1 answer
Using the debugger to find all strong references to an object
I have an object a1 of class A, I want to find all the objects that hold a strong a reference to the object a1.
Is there a way to do it?
The reason I want to know this is because, a1 doesn't seem to be deallocated.
user1046037
- 14,608
- 12
- 79
- 117
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