views:

28

answers:

2

Hi everyone,

I am trying to find my way into Obj-C for iPhone programming using this tutorial. In the end, what ever menu point you choose, SubViewOne was displayed.

I want to change this and in the end SubViewTwo(.xib) should appear when tapping the menu point "Sub View Two"

So what i did was changing the second repeat of

SubViewOneController *subViewOneController = [[SubViewOneController alloc] init];  
    subViewOneController.title = @"Subview One";  
    [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:  
          @"Subview One",         @"title",  
          subViewOneController,   @"controller",  
          nil]];  
    [subViewOneController release];

to

subViewTwoController = [[SubViewTwoController alloc] init];  
    subViewTwoController.title = @"Subview Two";  
    [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:  
                      @"Subview Two",           @"title",  
                      subViewTwoController, @"controller",  
                      nil]];  
    [subViewOneController release];

what gives me the error "SubViewTwoController undeclared (first use in this function)

I am quite new to this language so i would really appreciate it if you would leave some suggestions with a short explanation!

Thanks a lot in advance!

A: 

It looks like you just haven't declared the variable it should be:

SubViewTwoController *subViewTwoController = [[SubViewTwoController alloc] init];  
    subViewTwoController.title = @"Subview Two";  
    [views addObject:[NSDictionary dictionaryWithObjectsAndKeys:  
                      @"Subview Two",           @"title",  
                      subViewTwoController, @"controller",  
                      nil]];  
    [subViewOneController release];

the difference being:

SubViewTwoController *subViewTwoController

It also looks like the header file for SubViewTwoController is not included in the class, its a bit tough to tell with the limited amount of code you've posted.

You can include that header file like so assuming it is defined.

#import "SubViewTwoController.h"
paulthenerd
A: 

Thanks a lot for the answer! The error still exists.

the header file is already imported with

#import "SubViewTwoController.h"

at the start of the document. it has the following content

#import <UIKit/UIKit.h>


@interface SubViewTwo : UIViewController {

}

@end

I assume there is an "@interface" declaration missing. Does this help you?

benny