Chapter 1: A Simple iOS Application


#1

First of all, congratulations on a great book. However, there seems to be a small problem in Chapter 1 with the initWithNibName.

For some reason the super call is throwing an error saying “Expected expression.”

If I comment out the super call the application runs as expected. Also, if I put the code into the viewDidLoad all works well.

Has there been a change of specification for initWithNibName?

Thanks.


#2

Hard to tell without seeing the code.


#3

You most likely left in the placeholders. Read the paragraphs after that… the placeholders are somewhat hard to see.


#4

Exactly the mistake I made. Took 5 minutes to realize it!


#5

I must be incredibly dumb but what exactly do we put in place of the placeholders? The book says “The fix is to delete the placeholders and type in arguments of your own (with the same name).” Ok, but what arguments should we put there? I’m already stuck and feeling pretty bad about my prospects of getting through a book that stumps me in Chapter 1 :slight_smile:

Do we literally just make something up?

What am I missing?

Sorry.


#6

Your are not dumb; you are an outlander in a new land.

Please post the code for the method containing the piece of code giving you the headache.


#7

Relevant code is below. The problem is only with this line…“self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]”

It’s saying “expected expression” for each placeholder (i.e. nibNameOrNil and nibBundleOrNil), but I have no idea what to put there. I assumed the book would tell me but I don’t think it does, so I must be missing something really obvious :slight_smile:

[code]
@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) {

    }
    return self;
    }
    @end[/code]

#8

Delete the placeholder and type in the text that is there


#9

Sheesh, thanks Joe!