Questions tagged [dealloc]

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.

497 questions
5
votes
2 answers

iphone app with multiple views/subviews: memory is not being deallocated

I have an iPhone application that loads succesive views in a framework based on the one explained in this link (basically a main ViewController that loads/removes additional views with a displayView method). In my application I am using NIBs (the…
mga
  • 1,960
  • 1
  • 23
  • 31
4
votes
2 answers

Under Automatic Reference Counting (ARC), where do I put my free() statements?

In cocoa, ARC frees you of having to worry about retain, release, autorelease, etc. It also prohibits calling [super dealloc]. A -(void) dealloc method is allowed, but I'm not sure if/when it's called. I get how this is all great for objects,…
Olie
  • 24,597
  • 18
  • 99
  • 131
4
votes
1 answer

Getting "deallocated while key value observers were still registered with it." errors after conversion to ARC

I am using this class: https://github.com/alexleutgoeb/ALPickerView Since I converted to ARC, I get this error after clicking on the pickerview a couple of times: 2011-10-18 14:10:19.424 MappingApp[3398:10d03] An instance 0x73c7cd0 of class…
4
votes
2 answers

Is it necessary to add a dealloc method in a Objective-C Class?

If a UIviewController subclass is created, the method 'dealloc' is created automatically for you. - (void)dealloc{} However, when I create a Objective-C Class, the method is not auto-created. Is it necessary to add the dealloc method so that I can…
Zhen
  • 12,361
  • 38
  • 122
  • 199
4
votes
2 answers

Dealloc method disappeared from XCode 4.1 UIViewController template

I have been using XCode 3.2.4 when started developing iOS apps but now I turned to XCode 4.1 with iOS 4.3 SDK. I noticed that now dealloc method is not added automatically when I create UIViewController class from XCode template as were in XCode…
Mitry
  • 375
  • 4
  • 13
4
votes
3 answers

Best practices for releasing retained views?

Is this the correct (best?) way to release views retained in viewDidLoad, in iOS 4.x or lower? Is there anything else to consider? - (void) viewDidUnload { [super viewDidUnload]; [self releaseViews]; } - (void) dealloc { [self…
hpique
  • 119,096
  • 131
  • 338
  • 476
4
votes
4 answers

does dealloc method being executed normally when quitting the application?

I use code like the following (inside my appController.m for example) to do some cleanup when my application terminates... - (void) dealloc { [myObject release]; // myObject 's dealloc will not be called either !!! [arraySMSs release]; …
Vassilis
  • 2,878
  • 1
  • 28
  • 43
4
votes
2 answers

NSTimer with weak self; why is dealloc not called?

Consider view controller with strong(or weak, the same) NSTimer property: __weak __typeof(self) ws = self; self.timer = [NSTimer scheduledTimerWithTimeInterval:2 target:ws selector:@selector(timerTigger:) userInfo:nil repeats:YES]; But why does…
huangxinyu
  • 247
  • 3
  • 11
4
votes
1 answer

Push viewcontroller which is an instance variable, dealloc method won't be called when pop it

I have an AViewController, if I create BViewController as an instance variable like this @interface AViewController () { BViewController *bVC; } @end then push - (void)push { bVC = [[BViewController alloc] init]; …
xuning0
  • 105
  • 1
  • 10
4
votes
1 answer

Debugging disappearing button

I have a UIBarButtonItem embedded in a navigation item. It is positioned using the storyboard and at some point during runtime, it disappears. I have discovered that it is being deallocated. I could start browsing through my code, maybe doing a…
user1951992
4
votes
2 answers

Why objects are not dealloced in the dealloc method?

I have a problem understanding the Objective-C and the ARC. As I understood the strong pointers will be dealloced automatically for you, so you don't have to think about it (dealloced in dealloc method, or after the last time the object was used…
denis631
  • 1,765
  • 3
  • 17
  • 38
4
votes
1 answer

RestKit Core Data NSError dealloc Crash

Trying to get to the bottom of an issue I've been seeing in production builds and FINALLY was able to reproduce it while testing. Using RestKit v0.23.1, when doing an RKManagedObjectRequestOperation using the following code (while plugged into…
Mike
  • 9,765
  • 5
  • 34
  • 59
4
votes
1 answer

Cocoa NSWindowController And NSWindow Not Deallocing

I'm working with an NSWindowController to implement a preferences window. Apple's documentation states that by default the controller and window aren't deallocated, because it's useful to not have to reload everything, which makes sense. But their…
gngrwzrd
  • 5,902
  • 4
  • 43
  • 56
4
votes
2 answers

Cocos2d touch dispatcher causing object retain

I have a problem with cocos2d. I made a class which receives touches. Class is a subclass of CCLayer and init looks like so: - (id)initWithFrame:(CGRect)frameSize { self = [super init]; if (self) { frame = frameSize; size…
Majster
  • 3,611
  • 5
  • 38
  • 60
4
votes
1 answer

Climbing CFData memory usage when using Core Image filters

I'm having a problem with too much allocated memory. My app alloc mem reaches up to 100MB! And yes... i'm using ARC. most of memory allocated is by CFData(as i understand it is CoreImage filters). After applying filter to image, CFData allocated…