Reputation: 103
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:"LocalizeMeViewController.xib (es)"
bundle:[NSBundle mainBundle]];
Thanks in Advance........
Upvotes: 0
Views: 249
Reputation: 45138
Just do:
SpanishViewController *spanishview = [[SpanishViewController alloc]
initWithNibName:@"LocalizeMeViewController"
bundle:nil];
Upvotes: 0
Reputation: 33146
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.
Upvotes: 1
Reputation: 3361
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"
Upvotes: 0