Why does Objective-C allow a semicolon at the end of a method definition? [duplicate]
Possible Duplicate:
Semicolon after the method name in Objective-C implementation file
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
{
self = [super initWithNibName:nibNameOrNil bundle:nibBund开发者_运维技巧leOrNil];
if (self) {
// Custom initialization
}
return self;
}
Why I add ; at the end of the function is also correct?
It's an Objective-C convenience. It's so that you can copy/paste the method signature line from your header file. It's one of those things that has been around since the NeXTStep days.
精彩评论