2013-05-15 58 views
1
  • 線程#7:TID = 0x2403,0x351b9010 libsystem_kernel.dylib mach_msg_trap + 20 frame #0: 0x351b9010 libsystem_kernel.dylib mach_msg_trap + 20 幀#1:0x351b920c libsystem_kernel.dylib mach_msg + 56 frame #2: 0x33672422 CoreFoundationCFRunLoopServiceMachPort + 126 幀#3:0x3367115a的CoreFoundation __CFRunLoopRun + 882 frame #4: 0x335f44dc CoreFoundation CFRunLoopRunSpecific + 300 幀#5:0x335f43a4的CoreFoundation CFRunLoopRunInMode + 104 frame #6: 0x30e8cbc8 Foundation + [NSURLConnection的(裝載程序)resourceLoadLoop:] + 308 幀#7:0x30e8ca90基金會-[NSThread main] + 72 frame #8: 0x30f205a0 Foundation _NSThread__main + 1048 幀#9:0x3709bc1c libsystem_c .dylib`_pthread_start + 320

我沒有使用ASINetworkQueue並通過一個urls數組來使用,並且我實現了requestFinished:方法,它被調用的很好。當請求沒有被迴應時,我收到了崩潰。常見asihttprequest runrequests碰撞

你能請一些人幫我嗎?

示例代碼段:

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:); 
+0

請解釋更多或者張貼一些代碼 – Shardul

+0

@Shardul代碼片段已添加。請給我建議。 – Bharath

+0

@Bharath我也得到同樣的錯誤在這裏...任何建議。 – maheswaran

回答

1

委託我在視圖控制器被釋放後被調用。因此,在發佈視圖控制器之前需要清理所有代表。這對我有用。

+0

它是固定的嗎?你做了什麼 ?請給我一些更詳細的信息 – maheswaran

+0

你需要接受你自己的回答 –

+1

@maheswaran,請在dealloc之前調用View Controller中的cancel方法來釋放(ASI請求)。 – Bharath