views:

47

answers:

1

I have an ipad App, which has categories (tableviewcontrollers inside it) and detail views which has a webview shows info of the row on tableview.

On didSelectRowAtIndexPath function of category table views i am using the code as:

DetayViewController *dvc = [[DetayViewController alloc] init];
Blog *b = (Blog *)[self.blogArray objectAtIndex:indexPath.row];
dvc.cagirilanBlog = b;
[self presentModalViewController:dvc animated:YES];

This works fine. But when using the app, if you click row in table view and open a detail page and close it for about 30 times, the application crashes and quit.

The warnings i get when the app crashes is like:

**Received memory warning. Level=1**

**Received memory warning. Level=2**

**Program received signal:  “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")**

When i dissmiss the modal view controller, i am releasing all the object i used on detail view. But the issue i can not solve is why is it crashing? is that a bug? Can not i use presentModalViewController more than 30 times?

Please help me.

Thanks.

+3  A: 

You need to release ressources that you have used (each memory allocations need to be released).

In your case :

[dvc release]

(If not, all objets you have released in dealloc method won't be called !)

You can also use the Leak performance tool provided with Xcode. (very useful for detecting memory leaks)

You should read this document : http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

William Remacle
Do this : DetayViewController *dvc = [[[DetayViewController alloc] init] autorelease];
William Remacle
Dear William, when i use this code: [dvc release]; on while creating DetayViewController,when i dismiss the modalviewcontroller,the app crashes because of the -dealloc method. For example it says: [DetayViewController urlReq]:message sent to deallocated instance 0x62c39d0after this,i tried to clean my dealloc method and dont release the objects manually, but even on this case, the app crashes unexpectedly and gives this error: -[DetayViewController respondsToSelector:]: message sent to deallocated instance 0x62ca070 and i can not understand.I am not using a method like "respondsToSelector" :(
cenk ebret
And if i use autorelease, the same errors.
cenk ebret
No, **do not** do what @William says in the first comment. Write `[dvc release];` instead, after you run the `[self presentModalViewController:dvc animated:YES];`. Never use `autorelease` if it isn't absolutely necessary.
Emil
Emil, i tried both, and none of them solved my issue. :S
cenk ebret
Yes, release has to be after presentModalViewController. Sorry, autorelease won't work.
William Remacle