1
  • 线程 #7:tid = 0x2403, 0x351b9010 libsystem_kernel.dylib mach_msg_trap + 20 frame #0: 0x351b9010 libsystem_kernel.dylibmach_msg_trap + 20 帧 #1:0x351b920c libsystem_kernel.dylib mach_msg + 56 frame #2: 0x33672422 CoreFoundationCFRunLoopServiceMachPort + 126 帧 #3:0x3367115a CoreFoundation __CFRunLoopRun + 882 frame #4: 0x335f44dc CoreFoundationCFRunLoopRunSpecific + 300 帧 #5 CFRunLoopRunInMode + 104 frame #6: 0x30e8cbc8 Foundation 0x335f + 308 帧 #7:0x30e8ca90 基础-[NSThread main] + 72 frame #8: 0x30f205a0 Foundation_NSThread__main + 1048 帧 #9:0x3709bc1c libsystem_c.dylib`_pthread_start + 320

我没有使用 ASINetworkQueue 并通过一组 url 使用,并且我已经实现了 requestFinished: 方法,该方法可以正常调用。当请求没有得到响应时,我收到了崩溃。

你能请人帮我吗?

示例代码片段:

A 类(包装类扩展 ASIHTTPRequest):

ASIHTTPRequest *httpRequest;

- (id)initWithURL:(NSString *)anURL errorInfo:(NSError **)error {
    if (self = [super init]) {
        NSURL *httpURL = [NSURL URLWithString:anURL];
    httpRequest = [self createASIRequest:httpURL];
    didFinishSelector = @selector(requestFinished:);
    didFailSelector = @selector(requestFailed:);
        return self;
    }
}

- (void)dealloc {
    if (httpRequest) {
       [httpRequest clearDelegatesAndCancel];
       [httpRequest release];
       httpRequest = nil;
    }
    [super dealloc];
}

- (ASIHTTPRequest *)createASIRequest:(NSURL *)url {
    ASIHTTPRequest *request = [[ASIHTTPRequest requestWithURL:url] retain];
    request.delegate = self;
    return request;
}

B类:

Request in loop:

 Class A *d = [[Class A alloc] initWithURL:url errorInfo:&pError];
 d.didFinishSelector = @selector(responseHandler:);
 d.didFailSelector = @selector(responseHandler:);
4

1 回答 1

1

释放视图控制器后调用委托方法。因此,需要在释放视图控制器之前清理所有代表。这对我有用。

于 2013-05-21T12:23:54.490 回答