pixelbitlabs
pixelbitlabs

Reputation: 1934

Why can't I push a new view controller onto the current view?

I am using the following code and getting the following errors:

Showing code used and errors with code

EDIT: See this if you cannot read the image above!

The "ChangePasscode" is currently declared as a class and is a view controller with .h and .m files along with a .nib file.

Why are these issues happening, what can I do to fix them?

Thanks!

Upvotes: 0

Views: 786

Answers (4)

FeifanZ
FeifanZ

Reputation: 16316

I'm going to say that you've not imported ChangePasscode.h in your current file.

Update: In response to comment thread below, you'll need to actually create a nav structure if you want to push view controllers. The preferred way in iOS 5 is as follows:

// AppDelegate.h
// …Other existing code
@property (nonatomic, retain) UINavigationController *navController;
@end

// AppDelegate.m
@synthesize navController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  self.window.rootViewController = navController;
  self.window.backgroundColor = [UIColor whiteColor];
  [self.window makeKeyAndVisible];
  return YES;
}

Upvotes: 1

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73678

I am thinking this is a classic case of circular references. Maybe the two classes reference each other? Because of this forward declaration you might get all kinds of warnings when trying to reference the class name or properties of the class that has the forward declaration.

Where all have you included ChangePasscode. Also use #import rather than #include.

UPDATE: To solve your ld: duplicate symbol... error

It seems that you are compiling the same class ChangePasscode two times in different places of your code. This may happen in the following cases.

  1. You have put the same class implementation into two different files
  2. You actually have just one implementation of this class, however you are also linking in your project a framework or library containing a class whose name is exactly the same of yours.
  3. You could also get this error if you mistakenly let XCode's auto-complete for #import statements specify the '.m" file for the 'duplicate' class instead of the '.h'.

Try finding in the whole project your class and make sure only one copy is available within your project.

Upvotes: 0

aahsanali
aahsanali

Reputation: 3547

use

@class ChangePasscode;

rather than using

#import ChangePasscode.h

Upvotes: 0

chewy
chewy

Reputation: 8267

change [NSBundle mainBundle] to nil make sure you have import ChangePasscode.h on top of the M file

Upvotes: 0

Related Questions