views:

431

answers:

2

Ahoy hoy everyone :)

Here is a list of links. You will need it when reading the post.

I am a newbie to Objective-C and try to learn it for iPhone-App-Development. I used the tutorial linked in the link list to create a standard app with a simple basic Navigation. This app contains a "RootView" that is displayed at startup. The startup screen itself contains three elements wich all link to SubViewOne. I have got it to work this far. So what i want to change is to make the second element link to SubViewTwo.

When i "Build and Go" it, i get the following errors:

RootViewController.m:

SubViewTwoController *subViewTwoController = [[SubViewTwoController alloc] init];

// SubViewTwoController undeclared (first use in this function)

and in SubViewTwoController.m

[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview

no superclass declared in @interface for ´SubViewTwoController´

and the same thing after

- (void)dealloc {
    [super dealloc];

I think you will also need the header files, so here they are!

RootViewController.h

#import <UIKit/UIKit.h>  

@interface RootViewController : UITableViewController {  
    IBOutlet NSMutableArray *views;  
}  

@property (nonatomic, retain) IBOutlet NSMutableArray *views;  

@end

SubViewOneController.h

#import <UIKit/UIKit.h>  

@interface SubViewOneController : UIViewController {  
    IBOutlet UILabel *label;  
    IBOutlet UIButton *button;  
}  

@property (retain,nonatomic) IBOutlet UILabel *label;  
@property (retain,nonatomic) IBOutlet UIButton *button;  

- (IBAction) OnButtonClick:(id) sender;  

@end

and SubViewTwoController.h

#import <UIKit/UIKit.h>


@interface SubViewTwo : UIViewController {
      IBOutlet NSMutableArray *views;  
}

@end

I would be really great if you would leave your ideas with a short explanation. Thanks a lot in advance!

benny

+1  A: 

A couple of things going on here:

  1. @interface SubViewTwo : UIViewController {

Your class is called "SubViewTwo", not "SubViewTwoController"

  1. no superclass declared in @interface for ´SubViewTwoController´

Your class is called "SubViewTwo", not "SubViewTwoController". You've probably got @implementation SubViewTwoController at the top of the file.

The easiest fix would be to change the @interface line in SubViewTwoController.h to read:

@interface SubViewTwoController : UIViewController {

Then don't forget to #import "SubViewTwoController.h in your RootViewController.m file.

Dave DeLong
thanks a lot for the help! It all compiles successfully. But now the app crashes when tapping the menu point wich should invoke SubViewTwo. See the error report here http://pastebay.com/51877
benny
and this is because i did this: http://theappleblog.com/2009/04/15/iphone-dev-sessions-create-a-navigation-based-application/#comment-39176
benny
Looks like you forgot an `@synthesize button;` in your .m file.
Dave DeLong
thanks one more time. i fixed it and the errors resulting of this. unfortunately the app keeps crashing/freezing. The debugger console gives the following outlet: "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController loadView] loaded the "SubViewTwo" nib but the view outlet was not set.'"See my code here:http://pastebay.com/52023
benny
It means you haven't hooked things up properly in your XIB file. Go back to the tutorial where it says "Highlight File’s Owner and then from the menu bar, click on Tools, then Identity Inspector." and rewire everything in Interface Builder.
Dave DeLong
A: 

Hi ther I am having problems with

I have

-(IBAction) OnButtonClick:(id) sender { HighScoresView * hsv = [[HighScoresView alloc] initWithNibName:@"HighScoresView" bundle:[NSBundle mainBundle]]; [self presentModalViewController:hsv animated:YES]; [hsv release]; }

Is says that HIghScoresViews is undeclared as well as hsv.

Where do I declare it, because I did in the header file with IBAction and a property and i synthesised it in the implementation file.

Is there any chance you could help me ?

Thank you in advance

Geo

Geo