dealloc

What is your preferred coding style for dealloc in Objective-C?

I know that discussions about coding styles tend to end in disaster and endless flame wars, but that’s not what I want to reach. During the last decade I mainly saw two different coding styles for dealloc methods in Objective-C. The first and most common one was to place dealloc at the bottom of the file. This is also the style Apple use...

Force explicit deletion of a Java object.

I'm working on a Java server that handles a LOT of very dense traffic. The server accepts packets from clients (often many megabytes) and forwards them to other clients. The server never explicitly stores any of the incoming/outgoing packets. Yet the server continually runs into OutOfMemoryException exceptions. I added System.gc() into ...

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 = [[NSMutableArray alloc] init]; } I click a test-button to load my array (eventually it will...

How can't I occur an Error when using NSURLConnection ?

a scenario is below. I made two Controllers, A tableViewController, B viewController and C ScrollView. A tableViewController has cell that is entering to B viewController. and B viewController has C scrollView that is B's front View. C scrollView has object of NSURLConnection. and this functioned to download an image. ( A -> pushViewC...

[release] strategy for two mutually exclusive UIViews (iPhone)

Hi I have been doing spring cleaning in my app. I noticed something strange, that, when I tried to correct it, completely crashes my app. There are two "paths" in my app; either you are in the "A" part of it or you are in the "B" part. From the "A" part you can go to the "B" part and the other way around. I designed it so that the app ...

iPhone: Calling dealloc on parentViewController causes an exception

Hi, I'm dealing with viewDidUnload and dealloc methods and I've founded a problem when calling [super dealloc]; in parent view controller. I have a lot of view controllers with custom code which I have putted outside on a parent view controller. So, when defining my view controllers I set a reference to the super class: @interface Log...

Deallocating NSMutableArray of custom objects

I need help with deallocation of my NSMutableArray of custom objects. I need to retain the array and so I have added a property in .h and I release it in dealloc in .m file. When I add objects to the array, I do the following: myarray = [[NSMutableArray alloc] init]; [myarray addObject:[[mycustomObject alloc]initWithObject:obj1]]; ...

[CFArray release]: message sent to deallocated instance

Hi, I'm using the following method in my code: - (NSMutableArray *) newOrderedArray:(NSMutableArray *)array ByKey:(NSString *)key ascending:(BOOL)ascending { NSSortDescriptor *idDescriptor = [[NSSortDescriptor alloc] initWithKey:key ascending:ascending]; NSArray *sortDescriptors = [NSArray arrayWithObject:idDescriptor]; N...

iPhone: How to Stop Animations in a View Before the View Deallocates

I have added custom animation to UITableViewCells. Each cell has its own animation. When I pop the view, the animations continue and I get a bad exec error because the animation is trying to access the deallocated cells. How do I stop the animations before the view is deallocated? - (void)tableView:(UITableView *)tableView accessoryBu...

Object allocations in the cellForRowAtIndexPath method is increasing? Is dealloc not called in presentModelViewController?

Hi Guys, This is PresentModelViewController, when click a button i will get this "DoctorListViewController" controller from down. object allocation are not releasing in this controller specially in cellForRowAtIndexPath delegate method. UITableViewCell and two labels allocated in this is not releasing. In the previous view The allocat...

The dealloc method is not called in the present modal view contrller.

It is in My view controller -(void)doctorsListAction { if(isFirst == YES) { [self getDoctorsListController]; [[self navigationController] presentModalViewController:doctorListViewNavigationController animated:YES]; [doctorListViewController release]; } } -(void)getDoctorsListController { //Docto...

super dealloc error using multiple table view calsses

I am new to Iphone apps and I am trying to build a tab based app. I am attempting to have a table ontop of an image in both tabs. On tab with a table of audio links and the other tab with a table of video links. This has all gone swimmingly, I have created two viewControllers for the two tables. All the code works great apart from to ge...

Ambiguous scénario for iPhone memory management

Hey guys, i have some difficulties to understand this scénario ... i create an object i set its retained property to something i Forget to release its property i release the object as i didn't release the property in the dealloc method, Will the scénario result in a memory leak or Will the property be released automatically ? And ...

Signal "0" error while scrolling a tableview with images

Hi, I have a problem while scrolling images on tableview. I am getting a Signal "0" error. I think it is due to some memory issues but I am not able to find out the exact error. The code is as follows, - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSStri...

Object created in Interface Builder getting dealloc'ed too soon

The Project I'm working on a relatively simple iPhone OS project that's navigation controller based, with a root table view and a detail table view. Tap an item in the main list to see its details in a pushed table view. The Setup I broke out the data source for both views into their own objects so as not to muddy the purpose of a vi...

iPhone. Shouldn't hitting the home button cause UIApplicationDelegate's dealloc to be called

I have put NSLogs in all my classes including my UIApplicationDelegate subclass. I am curious - and a bit nervous - about why I am not seeing them echo anything when I press the home button. I am running in the XCode simulator. Since iPhone/iPad runs a single app at a time, doesn't hitting the home button discard all traces of the runni...

Need to dealloc all views in navigation controller

Hello, I'm trying to set up an in app purchase and once the purchase has been made I need to reset the app to its initial launch state. I'm wondering if there is a way to dealloc all the view controllers inside of each navigation controller and reload the initial view that is displayed when the app launches. Thanks in advance! ...

Objective-C NSDate memory issue (again)

I'm developing a graphing application and am attempting to change the renderer from OpenGL to Quartz2D to make text rendering easier. A retained NSDate object that was working fine before suddenly seems to be deallocating itself, causing a crash when an NSMutableString attempts to append it's decription (now 'nil'). Build & analyse doe...

What happens when you deallocate a pointer twice or more in C++?

int main(){ Employee *e = new Employee(); delete e; delete e; ... delete e; return 0; } ...

NSZombieEnabled breaking working code?

I have the following method in UIImageManipulation.m: +(UIImage *)scaleImage:(UIImage *)source toSize:(CGSize)size { UIImage *scaledImage = nil; if (source != nil) { UIGraphicsBeginImageContext(size); [source drawInRect:CGRectMake(0, 0, size.width, size.height)]; scaledImage = UIGraphicsGetImageFromCu...