views:

279

answers:

2

I'm currently setting up this view to be swapped with another in an iPhone game. When I use this code...

- (void)viewDidLoad {
     menuViewController = [[menuViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
     self.menuViewController = menuViewController;
     [self.view insertSubview:menuViewController.view atIndex:0];
     [menuViewController release];
}

...Xcode gives me a warning "'SomeViewController' may not respond to '-alloc'. I can't figure out how to get rid of this warning...can anybody help me?

Edit: Maybe this will help. In my .h file, I have this...

@interface RabbitReflexViewController : UIViewController {
    IBOutlet SomeViewController *menuViewController;
}

...along with some other code. My .m file contains what is above.

+5  A: 

In [someViewController alloc], someViewController should be a class name rather than an instance. So probably you want [SomeViewController alloc].

Steven Fisher
When I change my code to your suggestion, the warning goes away BUT when the iPhone Simulator launches, nothing loads at all (instead of the rest of the app launching).Yeah, I'm new to iPhone programming. :P
Kevin Y
You might check the console (Run | Console in Xcode) to see if any exceptions or other messages are being logged on startup of your application. If your application throws an exception for some reason, it will fail to start properly.
Brad Larson
+2  A: 

The problem here is not so much the compiler error as that you have no idea what you're doing. I'd recommend that you work your way through the tutorial material on the Apple developer site. That way you can progress from basic to more advanced material. Maybe start here: http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone101/Articles/00%5FIntroduction.html and http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning%5FObjective-C%5FA%5FPrimer/index.html#//apple%5Fref/doc/uid/TP40007594

Mark Bessey
That's a little harsh. This site is supposed to be friendly to new programmers, as well as more experienced ones.
Brad Larson
Yes, I am new to programming...which is why I'm posting here for help. That didn't help my figure out what the problem was, though. Thanks for the links, anyways, I'll read them.
Kevin Y
Sorry if that sounded harsh. Telling you how to "fix" the error isn't going to help much, you'll just run into some other problem you can't figure out in a day or two.You should find it much easier to start from the beginning. If you at least learn the Objective-C syntax, you won't have nearly as much trouble figuring out what the meaning of the error messages is.
Mark Bessey
Oh, and if you work through the "my first iPhone app" tutorial, you'll end up with working code for creating a hierarchy of view controllers, which you'll understand well enough to modify.
Mark Bessey
Yeah, I probably would run into another error. I guess I was expecting an answer and your response came as a surprise.I'll give the tutorial a good read and see if I understand it any better. Thanks for your help. ~
Kevin Y

related questions