I am getting the warning "warning: class 'Search' does not implement the 'ResultProtocol' protocol" even though Search is not suppose to implement ResultProtocol.
I have three protocols: SearchProtocol, ResultsProtocol, and ResultProtocol. SearchProtocol defines a method that returns id<ResultsProtocol>, and ResultsProtocol defines a method that returns id<ResultProtocol>. I am having a tough time getting to the bottom of this.
These classes implement the protocols and make calls
And this is the main page that gives the warning "warning: class 'Search' does not implement the 'ResultProtocol' protocol".
I'm not sure if this was too much or not enough details, so please let me know if you need to see anything else. Every class does implement the functions of its protocol. Maybe the warning is propagating from a lower level like Results or Result. I just don't know where to look anymore.
I have three protocols: SearchProtocol, ResultsProtocol, and ResultProtocol. SearchProtocol defines a method that returns id<ResultsProtocol>, and ResultsProtocol defines a method that returns id<ResultProtocol>. I am having a tough time getting to the bottom of this.
PHP:
//SearchProtocol.h
#import "ResultsProtocol.h"
@protocol SearchProtocol <NSObject>
- (id<ResultsProtocol, UITableViewDataSource>)results;
@end
//ResultsProtocol.h
#import "ResultProtocol.h"
@protocol ResultsProtocol <NSObject>
- (id<ResultProtocol,UITableViewDataSource>)resultAtIndexPath:(NSIndexPath *)indexPath;
@end
//ResultProtocol.h
@protocol ResultProtocol <NSObject>
+ (NSArray *)doSomething:(NSString *)foo;
- (void)doSomethingElse:(NSString *)bar;
@end
PHP:
//Search.h
@interface Search : NSObject <SearchProtocol,UITableViewDataSource>
{...}
@end
//Search.m
@implementation Search
- (id<ResultsProtocol,UITableViewDataSource>)results {
Results *results = [[[Results alloc] init] autorelease];
return results;
}
@end
//Results.h
@interface Results : NSObject <ResultsProtocol,UITableViewDataSource>
{...}
@end
//Results.m
@implementation Results
- (id<ResultProtocol, UITableViewDataSource>)resultAtIndexPath:(NSIndexPath *)indexPath {
Result *result = [[[Result alloc] init] autorelease];
return self result;
}
@end
//Result.h
@interface Result : NSObject <ResultProtocol,UITableViewDataSource>
{...}
@end
//Result.m
@implementation Result
//Implements functions in protocol
@end
PHP:
//implementation of MainDataSource.m (a root class that calls search)
- (void)fooBar: {
Search *search = [[[Search alloc] init] autorelease];
//WARNING HAPPENS AT LINE BELOW
[[SearchViewController alloc] initWithSearch:search] autorelease];
}
//SearchViewController.h
@interface SearchViewController : UIViewController
{...}
@property (nonatomic,retain) id<SearchProtocol, UITableViewDataSource> search;
@property (nonatomic,retain) ResultsViewController *resultsViewController;
- (id)initWithSearch:(id<SearchProtocol,UITableViewDataSource>)search;
@end
//SearchViewController.m
@implementation SearchViewController
- (id)initWithSearch:(id<SearchProtocol,UITableViewDataSource>)search {
if (self = [super init]) {
[self setSearch:search];
}
return self;
}
@end