2

i ve got a view controller containing four buttons..clicking on each button takes you to new view controller containing web view.everything works fine except when the button is clicked ..it takes you to the web view if i m to navigate back the app quits...in debug mode i ve got dis exception EXC_BAD_ACCESS...below is the code...

-(IBAction)Button1
{

WebViewFaceBook *newEnterNameController4 = [[WebViewFaceBookalloc]initWithNibName:@"WebViewFaceBook" bundle:[NSBundle mainBundle]];

    [[self navigationController] pushViewController:newEnterNameController4 animated:YES];

[newEnterNameController4 release];

}


- (void)viewDidLoad {
    [super viewDidLoad];

    //[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
    urlAddress2 = @"http://www.facebook.com/livingwaterscf";

    url2 = [NSURL URLWithString:urlAddress2];

    requestObj2 = [NSURLRequest requestWithURL:url2];

    [webViewFaceBook loadRequest:requestObj2];
}
kingston
  • 1,553
  • 4
  • 22
  • 42

3 Answers3

4

Are you releasing the webView in dealloc? Are you using any delegate methods of the webview?

Checkout NSZombieEnabled for your active executable to see some more info on the bad access.

These assignment won't work without declaration of ivars/properties:

urlAddress2 = @"http://www.facebook.com/livingwaterscf";

url2 = [NSURL URLWithString:urlAddress2];

requestObj2 = [NSURLRequest requestWithURL:url2];

Can you please show us the definition of those in your header file?

Edit

Change your declaration of urlAddress2, url2 and requestObj2 to retained properties and set them with self.urlAddress2 = xxx, then you can release them in dealloc. The class methods as well as the @"http://www.facebook.com/livingwaterscf" return autoreleased instances. If you want to own them you have to retain those and only then you should release them.

If you don't want to own them, and in this case I don't think you need those anywhere else then starting the load of the webview's content, just don't release them in dealloc!

Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
  • i ve released my webview in dealloc...i m not using any delgate..just the above code..but still getting EXC_BAD_ACCESS – kingston Apr 25 '11 at 10:02
  • So have you set NSZombieEnabled to YES? Anything new then on the console? – Nick Weaver Apr 25 '11 at 10:07
  • using nszombie got dis message--[CFURL release]: message sent to deallocated instance 0x6317940 ...cud u help me out – kingston Apr 25 '11 at 10:12
  • Please show us the declarations as shown in my updated question. – Nick Weaver Apr 25 '11 at 10:16
  • NSString *urlAddress2; NSURL *url2; NSURLRequest *requestObj2; IBOutlet UIWebView *webViewFaceBook;these are the four declarations and i m deallocating all four in dealloc method – kingston Apr 25 '11 at 10:18
1

You try to access something that has been deallocated.

Enable NSZombie to find out where.

Community
  • 1
  • 1
  • i ve got dis message...[CFURL release]: message sent to deallocated instance 0x6317940...cud u help me out – kingston Apr 25 '11 at 10:13
  • @user652878 you release `url2` somewhere, but you should not since it is autoreleased. –  Apr 25 '11 at 10:26
0

You may be release url2 in dealloc method in your WebViewFaceBook controller.

requestObj2, url2, urlAddress2 already autoreleased. You mustn't release them in dealloc

Alex Nazarov
  • 1,178
  • 8
  • 16