views:

45

answers:

2

i get this error "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?

+3  A: 

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.

Vladimir
okay, i understand now. thanks for the quick response
Joe
+1  A: 

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]];
Helen