dealloc

Custom class deallocated as soon as the app starts.

Heya, I've added a class object to the nib file. All connections are made. But for some reason, the object is deallocated as soon as it's created. Here's the code: control.h: #import <Foundation/Foundation.h> @interface control : NSObject { IBOutlet UILabel *PlayerScore; } -(IBAction) addPoint: sender; -(void) dealloc; @end c...

Objective-C object release and allocation timing

The code for this question is too long to be of any use. But I'm pretty sure my problem has to do with releasing a class. I have a helper class, ConnectionHelper.h/.m, that handles a NSURLConnection for me. Basically, I give it the URL I want and it returns the data (it happens to do a quick json parse on it too). It has a delegate w...

How can i see if dealloc is being called on a uikit object, or any object not created by myself

I think i have an UIImage that has a higher retain count than it should have and i am probably leaking memory. I use this image as a thumbnail, to set a custom background to a uibutton. So the uibutton is holding a reference to it and so do i. But instead of 2, the retainCount is 3. Do i have to create a custom UIImage derived class and ...

[super dealloc] Program received signal: “EXC_BAD_ACCESS”.

Hi, I am writing the code using cocos2d. I want to release all the memory I allocated. I have done it in dealloc method in the following way. All the objects I released are declared in interface file and property (assign) was set and are synthesized in implementation file. I used alloc method to create them like self.PlayerA = [[CCSpri...

dealloc vs. viewDidUnload

Hi I know this has been discussed here several times but I still can't get an answer to my problem. I've got a navigation controller app with a hierarchy of several view controllers. I had it crashing a lot until I learnt about the viewDidUnload method which (if I understood right) is triggered when a didRecieveMemoryWorning is being cal...

UINavigationController and UIViewController dealloc

Hi, I recently changed my app to use a UINavigationController, I was using a UINavigationBar before, with cascade subView adding, which was a bit tenuous. I'm facing a problem of memory usage. Leaks tool doesn't show any leak, but ViewControllers I create and add to the UINavigationController never seem to be released. So memory usage ...

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 somewhere? even if all of "bar"'s references are defined in "foo". thanks in advance. ...

ASIHTTPRequest dealloc and EXC_BAD_ACCESS problem

Hi, I'm using an array of ASIHTTPRequest wrappers (AsyncImageLoader) to download images for cells in a UITableView. I'm having problems handling ASIHTTPRequests lifetime. If I release them, I end up having a EXC_BAD_ACCESS if I keep scrolling up and down while they try to load images. Here's what my wrapper looks like. self.request ha...

Should -dealloc do anything other than release memory?

I inherited an iPhone app at work and I'm new to Objective-C so I don't have my bearings just yet. I encountered code similar to this: - (void) dealloc { [[StaticObject sharedObject] showSomeDialog]; [super dealloc]; } I know this is frowned upon in other languages. My spider sense is going crazy looking at that code. Is th...

iphone release dealloc

hi all! I wish best understand the difference between dealloc and release function.... example... I have my class derived from NSObject calle MyClass in my code, to use this class, I create an instance of MyClass.. // initialization MyClass* test = [[MyClass alloc] init]; //do some stuff.... // release?? [ test release]; is right?? ...

iPhone EXC_BAD_ACCESS when calling [super dealloc] on a custom UIViewController

I'm at a loss! It's one of those pesky bugs that happens only under specific conditions, yet I cannot link the conditions and the results directly. My app has a paged UIScrollView where each page's view comes from a MyViewController, a subclass of UITableViewController. To minimize memory usage I unload those controllers that are not c...

Problems releasing memory when popping a viewController using a navigationController

I'm having the following problem. When I pop the view controller pushing the back button, the dealloc method is not getting called. Here is the code I'm using: NSLog(@"coleccionVista retain count0: %i",[coleccionVista retainCount]); coleccionVista = [[coleccionViewController alloc] init]; NSString *nombreColeccion = [colecciones objec...

Releasing custom made NSObject class in iPhone App

Hi, I have a Class which I have created as an NSObject. This class has a number of properties of different types and methods etc. When I instantiate this class in my App (say in the main View Controller) I immediately send it a release call when I am finished using it. ie: MyObject *myObject = [[MyObject alloc] initWithParameters:pa...

Issues with NSOperationQueue and dealloc being called and crashing App

I've created an NSOperation in the queue like so: ImageLoadingOperation *operation = [[ImageLoadingOperation alloc] initWithImageURL:url target:self action:@selector(didFinishLoadingImageWithResult:)]; [operationQueue addOperation:operation]; [operation release]; And this works fine but if the view gets popped before the operation fin...

When to release a UIView that is removed from superview

I am creating a loading screen UIView which is added to a subview while some XML is parsed from some URL. Once the XML is returned, the loading screen is removed from its superview. The question I have is how should I release this object? In the code below, you'll see that I send removeFromSuperview to the loadingScreen, but I still h...

iPhone - Memory management question ???

Let's say i have a navigation controller in my app delegate. Why is it necessary to release it on dealloc method in my appDelegate? When the dealloc method of my appDelegate is called, it means user is exiting the app, so the leak doesn't affect my application. So why would i release anything in dealloc method of my appDelegate? ...

NSTimer not stopping

I have a Class with a NSTimer *myTimer; variable. At some point I do: myTimer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(doStuff) userInfo:nil repeats: YES]; further, I have a method: - (void)doStuff { if(myTimer) { //do stuff } } and I stop my timer when the class is released through: ...

What is the best way to release sprite frames used in an animation?

Hi, I am creating an animation in a scene(the current level) and so in the init section I add the required frames into the spriteFrameCache. [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"OchoHit.plist"]; CCSpriteSheet *spriteSheet1 = [CCSpriteSheet spriteSheetWithFile:@"OchoHit.png"]; [self addChild:sprit...

iOS AVAudioPlayer multiple instances, multiple sounds at once

I am working on an interactive children's book for the iPad that has a "read to me" option. For each page (that has an index), theres an audio clip that produces the "read to me" feature. The feature works well, except for the fact that when I turn the page, the previous pages audio still plays, even when the new audio starts, here's my...

Suicide: Objective-C objects calling their own -dealloc methods on themselves

Is it good practice for an object in Objective-C to commit suicide? That is, for an object to declare [self dealloc] where -dealloc permits an orderly wind down as usual? What are the principal risks? As it happens I have a specific example, a custom timer object that extends NSObject and comprises an NSTimer instance and an NSUInteger ...