Problems with intializing new QuizViewController


Hi there,

I’m running Xcode version 4.6.2 and having troubles using initWithNibName: and other methods. They are simply not processing. Here is my code

#import "QuizViewController.h"

@interface QuizViewController ()

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

    // Call the init method implemented by the superclass
    self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil];
            if (self) {
                //create to arrays and make the pointers point to them
                 = [[NSMutableArray alloc] init];
                answers = [[NSMutableArray alloc] init];
                // Add a questions and answers to the arrays
                [questions addObject:@"What is 7 + 7?"];
                [answers addObject:@"14"];
                [questions addObject:@"What is the capital of vermont?"];
                [answers addObject:@"Montpelier"];
                [questions addObject:@"From what is cognac made?"];
                [answers addObject:@"Grapes"];
    //Return the address of the new object
    return self;




What errors are you getting and are you filling in the “placeholders” in the initWithNibName method?


I had a error because of the placeholders on mine… all i did was retype the names that were there and that worked so… try that.


I think the issue is with your version of xcode. I’m new to xcode, but like you I tried the book on xcode 4.6.2.
In this version of xcode, The QuizAppDelegate code doesn’t call initWithNibName in the code generated from options chosen when you follow book.

Solution for me was to install closest version to 4.3 that I could on my OS, which was 4.4.
This works fine. Probably easier to install 4.4 anyways, as I’m sure it’s not the only place where the latest version of xcode veers off from book in a way that is confusing :wink:


You should use the following style to replace initWithNibName according to Kitsune’s answer. It works!

- (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder]; if (self) { // Custom initialization } return self; }