开发者

initWithNibName use partial nib name rather than full nib name

So i want to initialise my view controller with a nib however i don't want to use the full name of the nib just the first four characters as the remaining characters vary.

As you can see below in my code all of my nibs follow a format the format is 1_somenumber_sometext. Somenumber is substituted with xibNumber, xibNumber is a number from 1 t开发者_StackOverflowo 10 this is calculated seperately and just added into the nib name, no need to worry about it.

NSString* xibName =[NSMutableString stringWithFormat:@"1_%@_sometext", xibNumber];

childController = [[CategoryOneDetailController alloc] initWithNibName:xibName bundle:nil];

Can anyone help me?


If xibNumber is a number (NSInteger or int), replace that %@ with %i. If it is a double or float, use %d or %f. %@ is a token used to signify an object, so it won't work for primitive types like NSInteger or int.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜