“‘BlahDataController’没有可见的@interface 声明了选择器‘aMethod:’"; [英] "No visible @interface for 'BlahDataController' declares the selector 'aMethod:'"

查看:14
本文介绍了“‘BlahDataController’没有可见的@interface 声明了选择器‘aMethod:’";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题的一个简单示例:

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"]);"我收到错误消息:‘BlahDataController’没有可见的@interface 声明了选择器‘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 dance"并没有解决问题
1) 清洁构建
2) 删除派生数据
3)完全关闭XCode并重新打开

Minor Update:
Doing the entire "xcode dance" didn't solve the issue
1) Clean Build
2) Delete Derived Data
3) 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.

这篇关于“‘BlahDataController’没有可见的@interface 声明了选择器‘aMethod:’";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆