Ios 选择器'的实例方法未知;receivedItemsJSON';
我正在尝试构建一个测试iOS应用程序来解析eBay API中的JSON,但我无法将响应转发给代理。我在ItemCommunicator实现中收到了我的Ios 选择器'的实例方法未知;receivedItemsJSON';,ios,objective-c,api,delegates,Ios,Objective C,Api,Delegates,我正在尝试构建一个测试iOS应用程序来解析eBay API中的JSON,但我无法将响应转发给代理。我在ItemCommunicator实现中收到了我的fetchingItemsFailedWithError和receivedItemsJSON方法的选择器未知实例方法的警告 XYZItemCommunicator.m: #import "XYZItemCommunicator.h" #import "XYZItemCommunicatorDelegate.h" @implementation XY
fetchingItemsFailedWithError
和receivedItemsJSON
方法的选择器未知实例方法的警告
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
xyzitem.h:
#import <Foundation/Foundation.h>
@protocol ItemCommunicatorDelegate;
@interface XYZItemCommunicator : NSObject
@property (weak, nonatomic) id<ItemCommunicatorDelegate> delegate;
@end
#导入
@协议项通信或网关;
@接口XYZItemCommunicator:NSObject
@属性(弱、非原子)id委托;
@结束
xyzitemCommunicationorDelegate.h:
#import <Foundation/Foundation.h>
@protocol XYZItemCommunicatorDelegate <NSObject>
- (void)receivedItemsJSON:(NSData *)objectNotation;
- (void)fetchingItemsFailedWithError:(NSError *)error;
@end
#导入
@协议XYZItemCommunicatorDelegate
-(void)receivedItemsJSON:(NSData*)对象表示法;
-(void)获取项目失败错误:(n错误*)错误;
@结束
检查您的协议名称。你从
项目通信或删除
换成
XYZitem通信或远程门
您将哪个对象(视图控制器)设置为此视图控制器的代理?无论设置为该视图控制器的委托的对象是什么,都必须实现这两种协议方法。