FelixF
FelixF

Reputation: 83

XCode compiler warning: 'class' may not respond to 'method'

I'm trying to get rid of a certain warning that keeps popping up.

This is part of my WordListTableViewController.m

#import "WordListTableViewController.h"
#import "XMLReader.h"
@implementation WordListTableViewController

- (void)viewDidLoad
{
    [superviewDidLoad];
    NSDictionary *status = [_mainDictionary retrieveForPath:@"Dealers"];
}

@end

The XMLReader.h file:

#import <Foundation/Foundation.h>
@interface XMLReader : NSObject <NSXMLParserDelegate]] >
{
    NSMutableArray *dictionaryStack;
    NSMutableString *textInProgress;
    NSError **errorPointer;
}
+ (NSMutableDictionary *)dictionaryForPath:(NSString *)path error:(NSError **)errorPointer;
+ (NSMutableDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)errorPointer;
+ (NSMutableDictionary *)dictionaryForXMLString:(NSString *)string error:(NSError **)errorPointer;
@end

@interface NSMutableDictionary (XMLReaderNavigation)
- (id)retrieveForPath:(NSString *)navPath;
@end    

The warning I'm getting is:

warning: Semantic Issue: 'NSDictionary' may not respond to 'retrieveForPath:'

It does actually respond just fine, but I cannot figure out how to organise my headers so that the compiler would know what will respond...

Would really appreciate some help on this :)

Upvotes: 0

Views: 888

Answers (3)

docchang
docchang

Reputation: 1125

Just need to import your category for your WordListTableViewController.m

#import "NSMutableDictionary+XMLReaderNavigation.h";

Upvotes: 0

Pawel
Pawel

Reputation: 4715

The answer is very simple, the category you've provided extends NSMutableDictionary, whereas the object you're sending message to is an instance of NSDictionary class.

Upvotes: 0

Perception
Perception

Reputation: 80603

Well, your category NSMutableDictionary (XMLReaderNavigation) was added to NSMutableDictionary, and not NSDictionary. As it is, at runtime the method does exist on your actual allocated object, so it is invoked successfully. From the point of view of the compiler though, NSDictionary in fact does NOT respond to the retrieveForPath method.

Upvotes: 4

Related Questions