"Cannot find protocol declaration for ..." when accepting class c target

I'm currently a little upset with the user delegation process in objective-c. I have used the design template several times and I understand how it works. I searched the Internet for 2 hours, trying to find what I am doing wrong in this case, and do not prevail. I also compared my past use to user delegates that function properly against this instance and cannot see any conceptual differences. so we go:

I create a custom view with two tables (one table for the list, and the other for storing the ones selected from this list.) So that the user can make a basic choice. 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 

Pay attention to the official protocol announcements. Also note that this, along with compiling the .m file, is excellent. When I try to write a class to accept the protocol, I get the error message “Cannot find the protocol declaration for“ ListSelectorDataSoure. ”I get the same message for“ ListSelectorViewDelegate. ”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 import ListSelectorViewController.h, where protocol declarations are found. Also note that when you enter "", it automatically terminates, which means that it sees it. As I said, I did it exactly for other objects without any problems and I can’t wrap my head around it ... Any help at all will be appreciated

+4
source share
7 answers

Well understood ... a very 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 .h and .m were not visible to the rest of the project and were the cause of the error. just added a new file to the project and copied the contents of the source class.

+8
source

I also got this problem. This is an xcode error.

my delegate protocol file was modified using git merge merge, I fixed the conflict, but all my files using this delegate still cannot find this delegation protocol file.

therefore, I delete these two files by reference and add them to the project again. it worked!

+5
source

If ListSelectorViewController.h also imports ListSelectorDelegateTemplate.h, you will get such errors. You must transfer any files you import to the ".m" file and, if necessary, replace them with @class .

+2
source

Today is the same problem. This seems to be an xcode error.

Anyway, my solution was to create an empty h. file, declare your protocol there, and then #import this new h. file anywhere I used it.

0
source

You put my protocol declaration in a separate file and then imported it

0
source

what worked for me was a simple project wire (shift + command + K).

0
source

In my case, the error was caused by the cyclical #import. The delegate protocol declaration file included the delegate developer. The developer included a delegate protocol declaration file.

0
source

Source: https://habr.com/ru/post/1332613/


All Articles