开发者

iPhone: Error when using -(id)initWithNibName

I am trying to use the following code, but I always get an error that I can find little information about:

- (id)initWithNibName:@"MyRidesListView" bundle:nil {
    if ((self = [super initWithNibName:@"MyRidesListView" bundle:nil])) {
        // Custom initialization
    }
    return self;
}

Error:

expected identifier before 'OBJC_STRING' token

This seems like a simple method 开发者_StackOverflow社区to be calling. This is for a UINavigationController.

Ideas?


It looks like you are trying to implement a constructor method in a subclass of UIViewController or UINavigationController.

YOur syntax is a bit off. Without seeing what you are doing in a broader context I don't really know what is going on here, but this might help you out a bit. Its the closesest to your code while being syntactically correct.

- (id)initWithNibName:(NSString *)nibNameOrNull bundle:bundle {
    if ((self = [super initWithNibName:nibNameOrNull bundle: bundle])) {
        // Custom initialization
    }
    return self;
}

Then you can do this outside of your class:

[[MyRidesListView alloc] initWithNibNamed:@"MyRidesListView" bundle:nil];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜