Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot find protocol declaration for ..." in adopting class objective c

I'm a little frustrated at the moment with the custom delegate process in objective-c. I've used the design pattern a few times already and have a pretty good understanding of how it works. I've searched the internet for 2 hours trying to find what I'm doing wrong in this instance, and to no prevail. I also compared my past use of custom delegates that are functioning properly vs. this instance and can't see any conceptual difference. so here we go:

I'm making a custom dual table view (one table for the list, and the other to hold the selections made from that list.) so that the user can make basic selections. here is the header file:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>


@protocol ListSelectorViewDelegate

-(void) listTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
-(void) selectTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

-(void) listTableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
-(void) selectTableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;

- (void)listTableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)selectTableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

@end


@protocol ListSelectorDataSource

-(UITableViewCell *)listTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
-(UITableViewCell *)selectTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

-(NSArray *)sectionIndexTitlesForListTableView:(UITableView *)tableView editStatus:(BOOL) status;
-(NSArray *)sectionIndexTitlesForSelectTableView:(UITableView *)tableView editStatus:(BOOL) status;

-(NSInteger)listTableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;
-(NSInteger)selectTableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;

@end

@interface ListSelectorViewController : UIViewController {

 //Delegate
 id <ListSelectorViewDelegate> listsDelegate;
 id <ListSelectorDataSource> listsDataSource;

 //Titles
 IBOutlet UINavigationBar *pageNavBar;
 IBOutlet UINavigationBar *selectNavBar;
 IBOutlet UINavigationBar *listNavBar;

 //Tables
 IBOutlet UITableView *selectTable;
 IBOutlet UITableView *listTable;

 //Table Data
 NSMutableArray *listItems;
 NSMutableArray *selectItems;

 //Search Bars
 IBOutlet UISearchBar *selectedSearch;
 IBOutlet UISearchBar *listSearch;
 BOOL listTableIsSearching;
 BOOL selectTableIsSearching;

}

@property(nonatomic,assign) id <ListSelectorViewDelegate> listsDelegate;
@property(nonatomic,assign) id <ListSelectorDataSource> listsDataSource;


-(IBAction) newItem:(id)sender;
-(IBAction) selectAll:(id)sender;
-(IBAction) clearSelections:(id)sender;

@end

Notice the formal protocol declarations. Also note that this, along with the .m file compile fine. When I try to write a class to adopt the protocol I get the error "Cannot find protocol declaration for "ListSelectorDataSoure" ". I get the same message for the "ListSelectorViewDelegate" as well. Here is the .h file for the delegate class:

#import <Foundation/Foundation.h>
#import"ListSelectorViewController.h"

@interface ListSelectorDelegateTemplate : NSObject 
 <ListSelectorDataSource,ListSelectorViewDelegate>{

}

@end

Note that I am importing the ListSelectorViewController.h where the protocol declarations are found. Also note that when typing " " it does auto complete which means it does see it. Like I said, I've done it this exact way for other objects with no issues and cannot wrap my head around this one ... Any Help at all would be greatly appreciated

like image 492
RBI Avatar asked Dec 08 '22 00:12

RBI


1 Answers

Ok figured it out.... extremely stupid answer here...

I originally created the ListSelectorViewController in a separate project and added it to the current project I'm working on... for some reason the .h and .m were not visible to the rest of the project and was the reason for the errors. simply added a new file to the project and copied over the contents of the original class.

like image 126
RBI Avatar answered Feb 08 '23 22:02

RBI