"incomplete implementation" error


#1

Second time this happened to me tonight. Am attaching a screenshot.

I’m getting an “incomplete implementation error” on this line:

@implementation QuizViewController



#2

Actually it is incomplete because you still need to implement the showQuestion and showAnswer functions. Also don’t forget to replace nibNameOrNil when calling the init method with the superclass.


#3

It is just a warning saying you have declared methods in the .h but haven’t defined them in the .m. As you work through the chapter, that problem will be solved.


#4

When you say this

Actually it is incomplete because you still need to implement the showQuestion and showAnswer functions. Also don’t forget to replace nibNameOrNil when calling the init method with the superclass.

What actually are you supposed to replace “nibNameOrNil” with in both places??

The book text just leaves the default in place and never actually says what to put in it’s place.

Thanks
Chuck.


#5

I have the exact same problem. I don’t know how to fix it. Where did I go wrong? Do I have to replace nibNameOrNil and nibBundleOrNil with something? It’s beyond me at this point.

Any help would be appreciated. I have the exact same code as on the screenshot posted above.

Any clues?

Thanks.


#6

The chapter asks you to build and run the application a few pages later, after you have entered all of the code. Before you have entered all of the code, you will get those warnings. You don’t have to worry about them, just keep going.


#7

with all due respect sir, i also have the same problem,. I can’t move on with the instructions to “play around” with the Quiz Application, not until those red markers are trimmed down.
However, since i don’t know what to put on those nibNameOrNil and nibBundleOrNil, i tried these to make the app build and run without errors:

i simply put “//” before: self = [super initWithNibName:<#nibNameOrNil#> bundle:<#nibBundleOrNil#>];, so,
from:

to:

I built it, run it, and viola! it works!


#8

If you notice when you copied and pasted the code, there are <# #> tags around two of the arguments, which are emboldened here:

self = [super initWithNibName:<#nibNameOrNil#> bundle:<#nibBundleOrNil#>];

If you notice in Xcode, both of those arguments have a slightly shaded rounded rectangle around them. These are placeholder arguments - not valid code. You will need to enter in the valid code (which is the exact same text as shown in the placeholder) for things to work.

Pages 18 and 19 cover this in detail. If you are on the Kindle or something else that doesn’t have page numbers, look for Figure 1.19 and the text before and after it.


#9

Here is my code in full.

I just want to say that I did review the placeholder problem, and there are no placeholders in it whatsoever. I typed it all out by hand and, when autocomplete did suggest something, I did not allow it to. If it did fill something in (with a placeholder, with the rounded gray rectangles), I deleted the placeholder and retyped it by hand.

It still says Incomplete implementation on the @implementation QuizViewController line near the top.

When I run the program, it will build successfully and run, open the simulator and show me the screen. If I press the “Show the question” button, it will quit and the debugger gives me a big error (Which I can copy/paste too if you wish). If, however, I choose to show the answers, the answers show up normally and nothing bad happens.

The following is all the code of the QuizViewController.m file. Please note that I cannot, for the life of me, figure out what is wrong. Maybe it’s something extremely simple which I missed? I went over it a few times but I’m at a total loss. Any help would be appreciated, and please excuse the lengthy post. :slight_smile: I’m simply determined to try to figure this out and continue with the lessons.

//
//  QuizViewController.m
//  Quiz
//
//  Created by Nathaniel Harari on 5/9/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "QuizViewController.h"

@interface QuizViewController ()

@end

@implementation 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 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:@"From what is cognac made?"];
        [answers addObject:@"Grapes"];
    
    }
    // Return the address of the new object
    
    return self;

}

- (IBAction)showquestion:(id)sender
{
    // Step to the next question
    currentQuestionIndex++;
    
    // Am I pas the last question?
    if (currentQuestionIndex == [questions count]) {
        // Go back to the first question
        currentQuestionIndex = 0;
    }
    
    // Get the string at that index in the questions array
    NSString *question = [questions objectAtIndex:currentQuestionIndex];
    
    // Log the string to the console
    NSLog(@"displaying question: %@", question);
    
    // Display the string in the question ield
    [questionField setText];
    
    // Clear the answer field
    [answerField setText: @"???"];
}

- (IBAction)showAnswer:(id)sender
{
    // What is the answer to the current question?
    NSString *answer = [answers objectAtIndex:currentQuestionIndex];
    
    // Display it in the answer field
    [answerField setText:answer];
}


@end

#10
  • (IBAction)showquestion:(id)sender

Objective-C is case sensative. This should be:

  • (IBAction)showQuestion:(id)sender

The init stuff is correct.


#11

Regarding the placeholder stuff: Xcode puts in gray backgrounded rectangles over items that are placeholders. These place holders get put in when Xcode completes the method call for you and they need to be replaced with real code. If you type in the method call without using Xcode’s code completion or copy and paste it from someplace else, you won’t have those placeholders. In this case, the author wants you to replace the placeholders (if you have them) which the parameters being passed into init. You are calling the super method and passing in the method arguments you were passed in your init method. This is a pretty common occurrence - call super first thing and pass it the same things you were passed.

I think this thread got a little confusing because you weren’t using the placeholders, we are passing the same named variables as the placeholder text, and we can’t see the gray boxes when stuff is posted into the forum.


#12

Aha! Thank you very much! :slight_smile:

Why didn’t it point to that line though? Maybe something about an undeclared variable or something? I wouldn’t ever have figured it out by pointing to something seemingly unrelated and telling me it’s not declared. :confused:

Now that it works (I tested it), I can continue with my exercises. Very appreciated. :slight_smile:


#13

Well, it’s perfectly valid to declare another method with the same name all in lower case, it’s not an error. And it’s okay to declare a method in your .m file that’s not in your .h file as long as you don’t try to call it. So, although the names seem to us very similar, to the computer they are completely unrelated. So it will keep insisting you haven’t implemented the one it’s looking for. So whenever you see that message you know it can’t find something in your .m file that it expects based on your .h file. I don’t think the error is pointing to the init method but to the start of the implementation a line or two above it.


#14

[quote=“JoeConway”]If you notice when you copied and pasted the code, there are <# #> tags around two of the arguments, which are emboldened here:

self = [super initWithNibName:<#nibNameOrNil#> bundle:<#nibBundleOrNil#>];

If you notice in Xcode, both of those arguments have a slightly shaded rounded rectangle around them. These are placeholder arguments - not valid code. You will need to enter in the valid code (which is the exact same text as shown in the placeholder) for things to work.

Pages 18 and 19 cover this in detail. If you are on the Kindle or something else that doesn’t have page numbers, look for Figure 1.19 and the text before and after it.[/quote]

thanks mr.Conway! I rewrote it and typed it letter by letter, rebuilt, and ran,.No problems so far… :slight_smile: Thank you!


#15

Thanks for the explanation. I’ll definitely be on the lookout for that from now on. I’m just so pleased you guys pointed it out and explained why. It’s very appreciated. Looking forward to working on some more chapters today. :slight_smile:


#16

[quote=“JanOriCab”][quote=“JoeConway”]If you notice when you copied and pasted the code, there are <# #> tags around two of the arguments, which are emboldened here:

self = [super initWithNibName:<#nibNameOrNil#> bundle:<#nibBundleOrNil#>];

If you notice in Xcode, both of those arguments have a slightly shaded rounded rectangle around them. These are placeholder arguments - not valid code. You will need to enter in the valid code (which is the exact same text as shown in the placeholder) for things to work.

Pages 18 and 19 cover this in detail. If you are on the Kindle or something else that doesn’t have page numbers, look for Figure 1.19 and the text before and after it.[/quote]

thanks mr.Conway! I rewrote it and typed it letter by letter, rebuilt, and ran,.No problems so far… :slight_smile: Thank you![/quote]

Thanks, Joe. The culprits in my code were the placeholders. I should have remembered from page 18.