Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Xcode 4 not throw a warning over my incomplete implementation of the UITableViewDataSource protocol?

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!)

like image 995
Mark Amery Avatar asked Oct 22 '22 06:10

Mark Amery


1 Answers

This is probably a bug in Xcode 4.

It appears to be fixed in Xcode 5, which warns you appropriately.

like image 157
Matthias Bauch Avatar answered Nov 15 '22 09:11

Matthias Bauch