ARC语义问题:Class没有可见的@interface声明选择器 [英] ARC Semantic Issue: No visible @interface for Class declares the selector

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

问题描述

非常基本的东西,但我无法解决问题所在。在我的项目中,我有一个名为TheFeedStore的类,有以下两种方法:

Pretty basic stuff but i am unable to troubleshoot where the problem is. In my project, i have a class named "TheFeedStore" with following two methods:

- (BOOL)hasItemBeenRead:(RSSItem *)item
{
   ............
}

- (void)markItemAsRead:(RSSItem *)item
{
  .........
}

I我正在使用以下类方法,因此其他类可以使用它来访问这些方法:

I am using the following class method so other classes can access these methods using it:

+ (TheFeedStore *) sharedStore
{
    static TheFeedStore *feedStore = nil;

    if (!feedStore) {
        feedStore = [[TheFeedStore alloc] init];
    }
    return feedStore;
}

在我的另一个课程中,我可以通过写作轻松访问上述方法

In one of my another class, i can easily access the above methods by writing

if ([[TheFeedStore sharedStore] hasItemBeenRead:item]) 

[[TheFeedStore sharedStore] markItemAsRead:entry];

但是在另一个类中,如果我尝试以类似的方式访问这些方法,我会收到错误 'TheFeedStore'没有可见的@interface声明选择器'hasItemBeenRead:

But in another class if i try to access these methods in a similar manner, i get the error "No visible @interface for 'TheFeedStore' declares the selector 'hasItemBeenRead:"


1)我已经从类中导入了TheFeedStore.h文件我是
访问TheFeedStore类的这些方法。

1) I have imported TheFeedStore.h file in the classes from i am accessing these methods of TheFeedStore class.

2)我已经检查了10次并且没有拼写错误。

2) I have checked like 10 times and there is no typo.

3)我访问的方法也在
TheFeedStore.h的头文件中声明

3) The methods i am accessing are also declared in the header file of TheFeedStore.h

UPDATE:为了检查,我已经在TheFeedStore.h中声明了另一个测试方法,同样的结果,一个类可以访问新创建的方法,而三个类中的其余类不能。

UPDATE: Just to check, i have declared another test method in TheFeedStore.h, same result, one class can access the newly created method while rest of the three classes cannot.

更新:我已尝试在TheFeedStore.h中创建更多方法,仅用于解决此问题。其他类也无法访问新方法。但是如果这些新方法的返回类型是(RSSChannel *),它是我项目中的另一个模型类,那么它们就变得可访问了。如果它们的返回类型不是某些类,如(void)和(BOOL)那么它们是不可访问的。这是我的TheFeedStore.h https://gist.github.com/jessicamoore112/5558473

UPDATE: I have tried creating more methods in the TheFeedStore.h just for troubleshooting this issue. The new methods are also not accessible from the other classes. But if the return type of these new methods is (RSSChannel*) which is another model class in my project, than they become accessible. If their return type is other than some class like (void) and (BOOL) then they are not accessible. Here is my TheFeedStore.h https://gist.github.com/jessicamoore112/5558473

推荐答案

您已经说过在头文件中使用@class而不是#import,您尝试访问的方法是在头文件中声明并且没有任何类型的拼写错误。

You have said that you are using @class instead of #import in your header files, the methods that you are trying to access are declared in the header files and there are no typos of any kind.

在这种情况下,通常没有人指出这个问题,但我还是会这样做,因为我有多次面对这样的问题。您可能已经创建了许多项目副本来处理每个功能并保持工作项目。

In such cases, usually no body points this issue but i am going to do it anyway because i have faced such issues many times. You have probably created many copies of your project to work on each functionality and also keeping a working project.

执行此操作时,有时Xcode仍在使用较旧的副本几个档案。这意味着当您尝试访问的方法未被您声明时,它仍在使用TheFeedStore.h的旧版本。

When you do this, sometimes Xcode is still using the older copies of few files. That means it is still using the older copy of the TheFeedStore.h when the methods you are trying to access were not declared by you.

如何解决此问题非常简单。转到您尝试访问方法的文件以及声明这些方法的文件。

How to solve this problem is very simple. Go to the file from which you are trying to access the methods and the files in which these methods are declared.

在右侧的实用程序部分中,检查身份和类型区域下的位置和完整路径。

In the Utilities section on the right hand side, check the location and full path under "Identity and Type" area.

首先检查项目的名称,如果它与您正在处理的项目名称不同,那么意味着Xcode仍在从项目的上一版本中提取文件的旧副本。在我的情况下,请参阅项目名称为13SampleMoreRequests的蓝色箭头。

First check the names of the project, if it is different from the project name that you are working on, that means Xcode is still pulling the old copies of the files from the previous revision of your project. See the blue arrows where the project name is 13SampleMoreRequests in my case.

如果此名称与项目名称相同,那么我的答案无法解决您的问题。如果它不同,您应该使用红色箭头指出的标志浏览新位置来使用该文件的新副本。

If this name is same as your project name, then my answer does not solve your problem. If its different, you should use the new copies of the file by browsing the new location using the sign that is pointed out by red arrow.

一旦浏览并使用新文件,您的问题将得到解决,您将能够访问这些方法。如果你仍然不能,复制这些文件,从项目中删除,然后再次添加它们,你将不会遇到这个问题。

Once you browse and use the new files, your problem will be solved and you will be able to access the methods. If you still can't, copy these files, delete from the project and then add them again and you won't face this problem.

希望这会有所帮助!

这篇关于ARC语义问题:Class没有可见的@interface声明选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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