How to declare nib file with initwithnib syntax It display 'Warning: passing argument 1 of initwithNibName:bundle: from Incompatible pointer type'
.
my statement is:
SpanishViewController *spanishview = [[SpanishViewController alloc]
initWithNibName:"LocalizeMeViewC开发者_JAVA百科ontroller.xib (es)"
bundle:[NSBundle mainBundle]];
Thanks in Advance........
Unless you really know what you're doing with custom NIB filenames, you should be loading NIBs like this:
self.myViewController = [[[MyViewController alloc] initWithNibName:nil bundle:nil] autorelease];
or:
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
Apple is liable to add some new feature in the future, unannounced, that depends upon this "I don't care, choose the NIB automatically, please" feature.
PS: "incompatible pointer type" means you tried to pass it a variable of the wrong "type". You probably wrote:
[... initWithNibName:"name" bundle:nil]
... i.e. forgot the "@" symbol. That turns it into a different type/pointer type to what is expected (a particular kind of string pointer).
EDIT: now that you've added your actual code, I suspect you're doing localization the wrong way. Check the Apple docs, but off the top of my head, you provide multiple copies of the same NIB with identical name, but stored in different sub-directories, one per language.
You are probably not putting the exact name of your xib. I wouldn't recommend putting parentheses on a Nib name. And as Adam said, you need to put a '@' before it, since it is still a NSString it gets as a parameter. So the name should be a NSString. @"myNibName"
Just do:
SpanishViewController *spanishview = [[SpanishViewController alloc]
initWithNibName:@"LocalizeMeViewController"
bundle:nil];
精彩评论