!Automatic Reference Counting Issue?


#1

I get the error noted in red below and cannot figure out why. It says its an Automatic Reference Counting Issue. As far as I can tell I have entered everything correctly.Can anyone tell me what I have done wrong? Thanks.

#import “QuizViewController.h”

@implementation QuizViewController

  • (id) intWithNibName: (NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
    //Call the initmethod implemented by the superclass
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; [color=#FF0000]CANNOT ASSIGN TO SELF OUTSIDE OF A METHOD IN THE INIT FAMILY[/color]
    if (self)
    {
    //Create two arrays and make the pointers point to them
    questions = [[NSMutableArray alloc] init];
    answers = [[NSMutableArray alloc] init];

      //Add 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:@"What is Cognac made of?"];
      [answers addObject:@"Grapes"];
    

    }
    return self;


#2

You got a typo in the method name:

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

should be

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

(Missing the i in init)


#3

Thanks Joe! Even after you pointed out the mistake I had to stare at it a few minutes to figure it out.