本文介绍了“没有可见的@interface for'BrahDataController'声明选择器'aMethod:'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我的问题的一个简单示例:A simple example of my problem:在BlahDataController.h中"Within the BlahDataController.h"@interface BlahDataController : NSObject-(NSString *)aMethod:(NSString *)theString;@end在BlahDataController.m中"Within the BlahDataController.m"#import "BlahDataController.h"@implementation BlahDataController-(NSString *)aMethod:(NSString *)theString{ return @"Something";}@end在BobViewController.h中"Within BobViewController.h"@interface BobViewController : NSObject-(void)aMethodOfSomeSort;@end在BobViewController.m中"Within BobViewController.m"#import "BobViewController.h"#import "BlahDataController.h"@implementation BobViewController-(void)aMethodOfSomeSort{ BlahDataController *blahDataController = [[BlahDataController alloc] init]; NSLog(@"%@",[blahDataController aMethod:@"Variable"]);}@end在线上NSLog( @%@,[blahDataController aMethod:@Variable]);我收到错误:没有可见的@interface为'BlahDataController'声明选择器'aMethod:'On the line "NSLog(@"%@",[blahDataController aMethod:@"Variable"]);" I'm receiving the error: "No visible @interface for 'BlahDataController' declares the selector 'aMethod:'"任何人都知道为什么会出现这个错误?Anyone know why this error is occurring? - = - = - = - = - = - = - = - = - = - = --=-=-=-=-=-=-=-=-=-=-事物是的,在我的实际程序中,我有相同的实现,它适用于以这种方式创建的数百种方法。但是,每隔一段时间,我就会在新创建的方法上收到此错误。我没有做任何不同的事情。它只是不会识别它新创造的存在。The thing is, in my actual program, I have this same implementation and it works fine for hundreds of methods created this way. However, every so often, I'll receive this error on a newly created method. I didn't make it any differently. It just won't recognize it's newly created existence. - = - = - = - = - = - = - = - = - = - = --=-=-=-=-=-=-=-=-=-=-这就是我目前正在解决的问题,虽然我不知道为什么编译器接受这种方式,但不是其他方式:This is how I'm currently going around it, although I have no idea why the compiler accepts this way, but not the other:修改BobViewController.m:Modify BobViewController.m:#import "BobViewController.h"#import "BlahDataController.h"#import "AnotherDataController.h"@implementation BobViewController-(void)aMethodOfSomeSort{ BlahDataController *blahDataController = [[BlahDataController alloc] init]; AnotherDataController *anotherDataController = [[AnotherDataController alloc] init]; [anotherDataController fixedMethod:blahDataController theString:@"Variable"];}@end在AnotherDataController.h中"Within the AnotherDataController.h"@interface AnotherDataController : NSObject-(void)fixedMethod:(BlahDataController *)blahDataController theString:(NSString *)theString;@end在AnotherDataController.m中"Within the AnotherDataController.m"#import "AnotherDataController.h"#import "BlahDataController.h"@implementation AnotherDataController-(void)fixedMethod:(BlahDataController *)blahDataController theString:(NSString *)theString{ NSLog(@"%@",[blahDataController aMethod:theString]);}@end并且......它的工作正常。 ..所以我想xcode只是无法识别一个类中的方法,并且在另一个类中应该正常工作......伙计,我不知道为什么会发生这个错误......And....it works just fine...So I imagine xcode is just failing to recognize the method in one class, and working as it should in another...Man, I have no idea why this error is occurring... - = - = --=-=-次要更新: 完成整个xcode舞并没有解决问题 1)Clean Build 2)删除派生数据 3)完全关闭XCode并重新打开Minor Update:Doing the entire "xcode dance" didn't solve the issue1) Clean Build2) Delete Derived Data3) Completely Close XCode and reopen推荐答案 tl; dr - 项目中的某个地方有一个重复的文件!去追捕它并毫不留情地摧毁它!tl;dr - There's a duplicate file somewhere in the project! Go hunt it down and destroy it mercilessly!好的,对于将来这个问题的所有人来说;这就是问题所在。Ok, for all those in the future with this issue; this is what the problem was.几个月前我做过BlahDataController。大约一周前,我重新构建了项目的文件夹,并将BlahDataController从名为Blah的文件夹移动到另一个名为Data的文件夹。I had made BlahDataController months ago. About a week ago, I restructured the folders of the project and moved BlahDataController from a folder called "Blah" to another folder called "Data".当我更改代码时对于Data文件夹中的BlahDataController,我的一个类可以看到更改的代码,但是,另一个类不能。When I changed the code for BlahDataController within the "Data" folder, one of my classes could see the changed code, however, another class couldn't.最终出现的问题是当我移动BlahDataController时,它实际上创建了它的副本。所以我在Data文件夹中有一个BlahDataController,在Blah文件夹中有一个旧的BlahDataController。即使旧的BlahDataController不再附加到项目管理器中的项目(xcode的左侧),物理文件仍然存在于文件夹中的事实导致了这个问题。What ended up being the issue was that when I moved BlahDataController, it actually created a copy of it. So I had a BlahDataController in the "Data" folder, and an older BlahDataController in the "Blah" folder. Even though the older BlahDataController was no longer attached to the project in the project manager (left side of xcode), the fact that the physical file still existed in the folder caused this issue.删除BlahDataController的重复旧版本后,问题已解决。After deleting the duplicate older copy of BlahDataController, the issue was resolved. 这篇关于“没有可见的@interface for'BrahDataController'声明选择器'aMethod:'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 07:42