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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:21:53+00:00 2026-06-10T07:21:53+00:00

I have a UIViewController with a custom init method that looks like this: –

  • 0

I have a UIViewController with a custom init method that looks like this:

- (id)initWithFrame:(CGRect)frame_ customObject:(CustomObject *)object_ {
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        self = [super initWithNibName:@"ArtistViewController_iPad" bundle:nil];
    } else {
        self = [super initWithNibName:@"ArtistViewController" bundle:nil];
    }

    [self.view setFrame:frame_];

    self.customObject = object_;

    return self;
}

But when [self.view setFrame:frame_]; is called, it crashes with this in the log:

(null)
libc++abi.dylib: terminate called throwing an exception

This is how I allocate the UIViewController from another UIViewController:

CGRect frame = self.view.frame;

artistViewController = [[ArtistViewController alloc] initWithFrame:frame customObject:anObject];

the frame exists. self exists from [super initWithNibName:bundle];

But self.view seems to not exist. The nib files exist and have their view outlet hooked up.

Why does this happen?

  • 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-10T07:21:54+00:00Added an answer on June 10, 2026 at 7:21 am

    You should not access the view from within the initializer. There are several more appropriate places to do this work, depending on what you really want to accomplish.

    Read the view controller lifecycle to understand where you may want to place your modifications.

    http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html#//apple_ref/doc/uid/TP40007457-CH10-SW1

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

Sidebar

Related Questions

I have custom UIViewController which looks like this. @implementation UIViewControllerCustom - (id)init { self
I have a custom UIViewController subclass that handles all the view initialization by itself
I have a few custom UITableViewCells - http://img11.imageshack.us/i/customfacilitiescell.png/ which are added to this UIViewController
In a custom UIViewController , if I have a member UINavigationController that I initialize
I have an custom UIVIewController that is the base class for other controllers and
I have a class that implements UIView and inside - (void)drawRect:(CGRect)rect method I add
I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with
I have a UINavigationController that pushes a custom UITableViewController onto the stack. This pushed
I have a custom UIViewController and custom UIView. I'd like to override the viewcontroller.view
I have member variables in my custom UIViewController that are defined as 'assign' (not

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.