I'm trying to build a test iOS app to parse JSON from eBay's API and I'm having trouble relaying the response over to the delegate. I'm receiving the warning:
No known instance method for selector
errors for both my fetchingItemsFailedWithError
and receivedItemsJSON
methods in my ItemCommunicator
implementation.
XYZItemCommunicator.m:
#import "XYZItemCommunicator.h"
#import "XYZItemCommunicatorDelegate.h"
@implementation XYZItemCommunicator
- (void)searchItems
{
NSString *urlAsString = [NSString stringWithFormat:@"http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=**************&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.12.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&sortOrder=PricePlusShippingLowest&paginationInput.entriesPerPage=7&outputSelector=AspectHistogram&itemFilter(0).name=Condition&itemFilter(0).value(0)=New&itemFilter(1).name=MaxPrice&itemFilter(1).value=450.00&itemFilter(1).paramName=Currency&itemFilter(1).paramValue=USD&itemFilter(2).name=MinPrice&itemFilter(2).value=350.00&itemFilter(2).paramName=Currency&itemFilter(2).paramValue=USD&itemFilter(3).name=ListingType&itemFilter(3).value=FixedPrice&keywords=Moto+x+16gb+unlocked"];
NSURL *url = [[NSURL alloc] initWithString:urlAsString];
NSLog(@"%@", urlAsString);
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (error) {
[self.delegate fetchingItemsFailedWithError:error];
} else {
[self.delegate receivedItemsJSON:data];
}
}];
}
@end
XYZItemCommunicator.h:
#import <Foundation/Foundation.h>
@protocol ItemCommunicatorDelegate;
@interface XYZItemCommunicator : NSObject
@property (weak, nonatomic) id<ItemCommunicatorDelegate> delegate;
@end
XYZItemCommunicatorDelegate.h:
#import <Foundation/Foundation.h>
@protocol XYZItemCommunicatorDelegate <NSObject>
- (void)receivedItemsJSON:(NSData *)objectNotation;
- (void)fetchingItemsFailedWithError:(NSError *)error;
@end
Check your protocol name. you start with
ItemCommunicatorDelegate
and change to
XYZItemCommunicatorDelegate