ios warning calling init method of a uiviewcontroller
I have my custom viewcontroller declared like this:
@interface DetailViewControllerSpeciality2 : UIViewController <UITableViewDelegate, UITableViewDataSource> {
}
and I create a new instance like this:
DetailViewControllerSpeciality2 *detailVi开发者_如何学GoewControllerSpeciality = [[DetailViewControllerSpeciality2 alloc] init];
but xcode tell me a warning:
multiple methods named '-init' found
but I don't have declared a -init method...
You aren't showing all the error message, nor the relevant code. Still, there is enough evidence to make an educated guess.
More likely than not, you have an init
method declared like:
- (DetailViewControllerSpeciality2 *) init;
The compiler is complaining because that conflicts with NSObject's init (that returns id
).
Declare your init
to return id
and the compiler should be happy. If that isn't the problem, post more code.
try this.
[[DetailViewControllerSpeciality2 alloc] initWithNibName:nil bundle:nil];
精彩评论