我的代码:
RKRequest.m:
#import "RKRequestDelegate.h"
#import "Constants.h"
@implementation RKRequestDelegate {
}
- (void)sendRequest:(UIImageView *)imageView {
NSDictionary *queryParams = [NSDictionary dictionaryWithObjectsAndKeys:@"0", @"w", @"4", @"section", @"0",
@"latitude", @"0", @"longitude", @"0", @"dt", @"0", @"di", nil];
NSString *plistPath = [[NSBundle mainBundle] pathForResource:[Constants getSettingsName]
ofType:[Constants getSettingsFormat]];
NSDictionary *contentDictionary = [NSDictionary dictionaryWithContentsOfFile:plistPath];
NSString *addedUrl = [contentDictionary valueForKey:[Constants getBannerTag]];
//
RKRequest *request = [[RKClient sharedClient] get:addedUrl queryParameters:queryParams delegate:self];
}
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response {
NSLog(@"Response!!!");
}
@end
RKRequestDelegate.h:
@interface RKRequestDelegate : NSObject <RKRequestDelegate>
- (void)sendRequest:(UIImageView *)UIImageView;
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response;
@end
AppDelegate.m:
RKClient *client = [RKClient clientWithBaseURL:[HttpUtil getHost]];
启动应用程序后,它会在 5 秒后崩溃。如果我更改delegate:self
为委托:[RKRequestDelegate class]
它不会崩溃,并给出响应 200(OK),但它没有回调 a didLoadResponse
!
请帮忙,谢谢。
更新:
如果我[request sendSynchronously];
在 RKRequestDelegate.m 中使用,则会调用响应。