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 8686989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:00:23+00:00 2026-06-12T23:00:23+00:00

I have a UISplitViewController which implements a masterNavigationController and a detailNavigationController , basic from

  • 0

I have a UISplitViewController which implements a masterNavigationController and a detailNavigationController, basic from the XCode template.

The masterNavigationController calls an other NSObject called “API” which in its turn uses ASIHTTPRequest to retrieve certain JSON data from an server.

Everything is fine and dandy, until I the call from the request starts. It shows the GUI of iPad and crashes straight after with an EXC_BAD_ACCESS. The error message I get is the following:

2012-10-10 21:13:42.357 myapp[24409:c07] Splitview controller
is expected to have a view
controller at index 0 before it’s used!

I have tried different things to try to solve the issue, one of them being setting the SplitViewController delegate after settings the view controllers, an other is using the NetworkQueue instead.

This is the code of the masterNavigationController:

[...]
- (void)viewDidLoad
{
    [UIHelper setNavigationBackBackground:self.navigationController.navigationBar widePage:NO];
    [UIHelper setViewBackground:self.parentViewController.view widePage:NO];
    [UIHelper setTableViewStyle:self.tableView];

    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.leftBarButtonItem = self.editButtonItem;

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
    self.navigationItem.rightBarButtonItem = addButton;

    API *api = [[API alloc] init];
    [api setDelegate:self];
    [api setDidFinishSelector:@selector(didFinish:)];
    [api getCommingRetrievals];
}
[...]

The AppDelegate:

[...]
    MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];

    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];

    masterViewController.detailViewController = detailViewController;

    self.splitViewController = [[UISplitViewController alloc] init];

    self.splitViewController.view.opaque = NO;
    self.splitViewController.view.backgroundColor = [UIColor clearColor];

    self.splitViewController.viewControllers = @[masterNavigationController, detailNavigationController];
    masterViewController.managedObjectContext = self.managedObjectContext;

    self.splitViewController.delegate = detailViewController;

    self.window.rootViewController = self.splitViewController;
    [self.window makeKeyAndVisible];
[...]

This is the API object’s code:

- (void)getCommingRetrievals
{
    [self getRetrievalsForDate:[NSDate date]];
}

- (void)getRetrievalsForDate:(NSDate*)date
{
    NSString *stringFromDate = @"";

    if (date != nil)
    {
        // Set date string
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyyMMdd"];
        stringFromDate = [formatter stringFromDate:date];
    }

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/bookings/%@", API_BASE_DOMAIN, stringFromDate]];
    [self callApi:url requestMethod:@"GET"];
}

#pragma mark - 
#pragma mark API methods

- (void)callApi:(NSURL*)url requestMethod:(NSString*)requestMethod
{
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setRequestMethod:requestMethod];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request setDidFailSelector:@selector(didFailWithError:)];
    [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    if (self.delegate && [self.delegate respondsToSelector:didFinishSelector]) {
        [self.delegate performSelector:didFinishSelector withObject:self];
    }
}

If I comment out the line [request startAsynchronous];, the app doesn’t crash.

What am I missing here, and how can I solve the problem?

  • 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-12T23:00:24+00:00Added an answer on June 12, 2026 at 11:00 pm

    Check that your UISplitViewController has been passed 2 view controllers.

    Other than that, some idiomatic stuff:

    This should go right at the beginning of any setting up stuff:

    [super viewDidLoad];
    

    e.g. `[super viewDidLoad]` convention

    And consider using another framework than ASI. It’s a dead library. AFNetworking, MKNetworkingKit or RESTKit are good alternatives.

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

Sidebar

Related Questions

I have a UISplitViewController in which i'm attempting to pass an int value from
I have a generic UISplitViewController (UITableView in the RootViewController and other stuff in the
I have an iPad App which uses a UISplitViewController as the root controller, I
I have a custom UIView, which I have placed using Xcode (4). I need
I have a UISplitViewController which has a UIWebView assigned to its detailedView. The problem
I have a UISplitViewController which has a UINavigationController in the master and a UIViewController
I have UISplitViewController that I want to be updated from a UIViewController that is
I have a UISplitViewController in an iPad app. When something is selected from the
In my project I'm using Reachability API. I followed the code example which have
In IOS5, with storyboards, suppose you have a UISplitViewController, which has some views that

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.