我收到以下錯誤「發送到釋放實例消息」指針:尋找關於如何調試
* -[URLViewController respondsToSelector:]: message sent to deallocated instance 0xdb5c3b0
,我很困惑如何開始調試這一點。有人可以給我一些關於從哪裏開始看的指針嗎?
這裏有一些代碼,如果你想看。這實際上是一個URL攔截器,讓每一個環節的presentModalViewController
- (BOOL)openURL:(NSURL *)url{
URLViewController * web = [[URLViewController alloc] init];
web.url = url;
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web];
[nav.navigationBar setTintColor:[UIColor blackColor]];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[self.detailViewController presentModalViewController:nav animated:NO];
[web release];
[nav release];
return YES;
}
如果URLViewController實現任何利益打開了,那就是:
@implementation URLViewController
@synthesize webview;
@synthesize url;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (IBAction) done:(id) sender
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction) openInSafari:(id) sender
{
[(CVore*)[CVore sharedApplication] openURL:url withOverride:NO];
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.webview.delegate = self;
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webview loadRequest:requestObj];
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]];
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(openInSafari:)]];
// Do any additional setup after loading the view from its nib.
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString* title = [webView stringByEvaluatingJavaScriptFromString: @"document.title"];
self.title = title;
//self.navigationItem.title = title;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
@end
UPDATE: 跟蹤此之後,我認爲我的錯誤在這裏是我需要將UIWebView委託設置爲零,然後[超級dealloc]這是正確的?當我這樣做時,它不再崩潰
@adit:如果我們有一些代碼可以幫助我們,那麼這將對我們有所幫助。 – SK9 2011-05-30 04:19:22
打開'NSZombies' – zneak 2011-05-30 04:29:47
沒有人想爲down vote.so刪除帖子是更好的選擇 – Ishu 2011-05-30 05:18:44