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(確定),但它沒有回調didLoadResponse
!
請大家幫忙,謝謝。
UPDATE:
如果我在RKRequestDelegate.m使用[request sendSynchronously];
,響應被調用。
你崩潰是幾乎可以肯定,因爲你委託的太早釋放。 –