Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:20:52+00:00 2026-06-01T12:20:52+00:00

I am having a really hard time getting this to work. I have two

  • 0

I am having a really hard time getting this to work. I have two view controllers with associated views called DomainSelectionViewController and DomainViewController. I’m going through a tutorial on Apple’s developer network that covers presenting view controllers. I’m getting an EXC_BAD_ACCESS signal when trying to run.

Here are the relevant excerpts from each file:

DomainSelectionViewController.h

@class DomainViewController;

@interface DomainSelectionViewController : UIViewController

- (IBAction)domainSelected:(id)sender;
- (IBAction)leaveDomain;

@property (retain) DomainViewController * selectedDomain;

@end

domainSelected: is attached to a button that represents a domain. Clicking on it successfully replaces the current view in the interface with the view defined in DomainViewController’s nib.

DomainSelectionViewController.m

@implementation
- (IBAction)domainSelected:(id)sender {
    NSLog(@"Domain Selected...");
    selectedDomain = [[DomainViewController alloc] initWithNibName:@"DomainView" bundle:nil];
    selectedDomain.domainSelectionContext = self;
    [self presentViewController:selectedDomain animated:NO completion:nil];
}

- (IBAction)leaveDomain {
    NSLog(@"Leaving Domain...");
    NSLog(@"Presented Domain: %@", self.presentedViewController);
    //selectedDomain.modalPresentationStyle = UIModalPresentationFullScreen;
    [self dismissViewControllerAnimated:NO completion:nil];
}

DomainViewController.h

#import <UIKit/UIKit.h>
#import "DomainSelectionViewController.h"

@class DomainSelectionViewController;

@interface DomainViewController : UIViewController

//@property (nonatomic, assign) DomainSelectionViewController * presentingViewController;
@property (nonatomic, retain) DomainSelectionViewController * domainSelectionContext;

@end

DomainViewController.m

- (IBAction)exit:(id)sender {
    NSLog(@"Leaving Domain...");
    if(self.presentingViewController) {
        NSLog(@"  Dismissing View Controller: %@.", self.presentingViewController);
        [self.domainSelectionContext leaveDomain];
        //[self.presentingViewController dismissViewControllerAnimated:NO completion:nil];
        return;
    }
    else {
        NSLog(@"Presenting view controller not set.");
    }
}

The domainview contains only one button that reads “back” and is connected to its own exit: function, which in turn calls leaveDomain on its delegate. It is on clicking on this button that the EXC_BAD_ACCESS call arises. Looking at other similar posts, it’s said that the EXC_BAD_ACCESS error typically arises from trying to call upon a deallocated object, but the print statement just before the dismiss call shows that the objects are still there and can be referred to. I was hoping someone with more experience than I could look at this and easily divine what has gone wrong.

For completeness’s sake, here’s the output from the console:

Attaching to process 26860.
2012-03-24 19:23:45.601 domaintest[26860:f803] DomainSelectionView Initialized.
2012-03-24 19:23:52.627 domaintest[26860:f803] Domain Selected...
2012-03-24 19:24:14.187 domaintest[26860:f803] Leaving Domain...
2012-03-24 19:24:14.188 domaintest[26860:f803]   Dismissing View Controller: <DomainSelectionViewController: 0x688f9a0>.
2012-03-24 19:24:14.188 domaintest[26860:f803] Leaving Domain...
2012-03-24 19:24:14.188 domaintest[26860:f803] Presented Domain: <DomainViewController: 0x6891d90>
Current language:  auto; currently objective-c
warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
(gdb)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:20:53+00:00Added an answer on June 1, 2026 at 12:20 pm

    So after quite a bit of trial-and-error, the issue here was higher up in the view hierarchy. The design had a root view controller that was completely empty, which replaced its own view with the first (DomainSelectionViewController) controller’s view

    self.window.rootViewController.view = domainSelectionViewController.view;
    

    The end result of which is that domainSelectionViewController could present domainViewController’s view, but trying to dismiss it resulted in EXC_BAD_ACCESS. I’m still not entirely sure why, but changing it such that domainSelectionViewController was the primary view, or having rootViewController present domainSelectionViewController in ViewDidAppear fixed the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a really hard time getting this marshalling down. I have umanaged
I have been having a really hard time debugging this error since the past
I am having a really hard time trying to get this to work. All
I'm having a really hard time with this one, EDIT: I'm putting this edit
This is pretty simple question, but I'm having really hard time with it. I
I'm having a really hard time getting my head around using REST-style URLS. Can
I'm having a really hard time understanding why I keep getting an exception, when
I'm having a really hard time understanding delegates and object inheritance (if I may
I am having a really hard time writing a SELECT query to get a
I just start playing with GWT I'm having a really hard time to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.