Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

iphone - ARC Semantic Issue: No visible @interface for Class declares the selector

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 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]) 

or

[[TheFeedStore sharedStore] markItemAsRead:entry];

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) I have imported TheFeedStore.h file in the classes from i am accessing these methods of TheFeedStore class.

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

3) The methods i am accessing are also declared in the header file of 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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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.

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.

utilities

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.

Hope this helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...