i get this error开发者_如何学C "expected identifier before 'OBJC_STRING' token" on this line of code:
- (id)initWithNibName:(NSString *)@"Landscape.xib" bundle:(NSBundle *)mainBundle {
and im not sure why, can anyone help?
In method declaration you can't use string literals for parameter name. Declare it
- (id)initWithNibName:(NSString *)name bundle:(NSBundle *)mainBundle {
...
and pass @"Landscape.xib"
as parameter when call that method
P.S. not sure if that's relevant to your question or not, but just in case - objective-c does not support default values for function parameters.
You cannot pass a string in like that. You would use:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)mainBundle {
...
}
and call it from some other line of code like this:
[[Class alloc] initWithNibName:@"Landscape.xib" bundle:[NSBundle mainBundle]];
精彩评论