If I declare and incompletely implement my own protocol using the following code in Xcode:
SomeProtocol.h:
@protocol SomeProtocol <NSObject>
@required
-(void)someRequiredMethod;
@end
SomeImplementor.h:
#import "SomeProtocol.h"
@interface SomeImplementor : NSObject <SomeProtocol>
@end
SomeImplementor.m:
#import "SomeImplementor.h"
@implementation SomeImplementor { // I get a warning on this line
}
@end
Then Xcode throws a warning on the @implementation
line of SomeImplementor.h, that reads as follows:
Incomplete implementation.
Method 'someRequiredMethod' in protocol not implemented.
However, if I incompletely implement the UITableViewDataSource
protocol from UITableView.h with the following code...
SomeClass.h:
@interface SomeClass : NSObject <UITableViewDataSource>
@end
SomeClass.m:
#import "SomeClass.h"
@implementation SomeClass { // I think I should get a warning here, but I don't
}
@end
... then Xcode is fine with it, and doesn't display a warning anywhere, even though I clearly haven't implemented the following methods from the UITableViewDataSource protocol:
@protocol UITableViewDataSource<NSObject>
@required
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Why? I can't see any reason that these two cases should be treated differently. (And I want my warnings!)
This is probably a bug in Xcode 4.
It appears to be fixed in Xcode 5, which warns you appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With