2010-04-30 2 views
0

보조 스레드에서 내 기능을 수행하고 결과를 얻으면 주 스레드에서 내 ViewController를 팝업하는 함수를 호출합니다. 하지만 다음 오류가 발생합니다 :보조 스레드의 주 스레드에서 UIPopoverViewController 호출

void WebThreadLockFromAnyThread(), 0x5c6dec0 : 주 스레드 또는 웹 스레드 이외의 스레드에서 웹 잠금을 얻는 중입니다. 보조 스레드에서 UIKit을 호출하면 안됩니다.. 나는 아래의 코드를 사용하고

:

-(IBAction)done{  
    if([self validateRegistrationDetails]){ 
    [NSThread detachNewThreadSelector:@selector(invokeWebService) toTarget:self withObject:nil]; 
    } 
} 

-(void) invokeWebService{ 
    NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init]; 
    NSString *url = [NSString stringWithFormat:@"%@%@action=1&userName=%@&eMail=%@&firstName=%@&lastName=%@&mobileNo=%@",kBaseURL,kRegisterFunction,userName.text,eMail.text,firstName.text,lastName.text,mobileNo.text]; 
    [ADCUtilities performSelectorOnMainThread:@selector(updateText:) withObject:@"Registering... "waitUntilDone:NO]; 
    [ADCUtilities performSelectorOnMainThread:@selector(showIndicator:) withObject:self.view waitUntilDone:NO]; 
    NSDictionary *tempDict = [webService makeAPICall:url]; 
    [NSThread sleepForTimeInterval:3]; 
    if(tempDict!=nil){ 
    NSString *tempLoginSuccess = [tempDict valueForKey:kLoginStatus] ; 
    if([tempLoginSuccess isEqual:@"LoginSuccess"]){ 
     [ADCUtilities displayAlertView:NSLocalizedString(@"REG_SUCCESS",@"")]; 
     [self performSelectorOnMainThread:@selector(popViewController) withObject:nil waitUntilDone:NO]; 
    } else { 
     [ADCUtilities performSelectorOnMainThread:@selector(dismissIndicator) withObject:nil waitUntilDone:NO]; 
     [ADCUtilities displayAlertView:NSLocalizedString(@"REG_FAILED",@"")]; 
    } 
    } else { 
     [ADCUtilities performSelectorOnMainThread:@selector(dismissIndicator) withObject:nil waitUntilDone:NO]; 
     [ADCUtilities displayAlertView:NSLocalizedString(@"REG_FAILED",@"")];  
    } 
    [pool release]; 
} 

-(void)popViewController{  
    [self.navigationController popViewControllerAnimated:YES];  
} 

답변

3

나는 당신의 문제는 실제로 내가 표시를 UIAlertView 어떤 종류의 가정 [ADCUtilities displayAlertView:NSLocalizedString(@"REG_SUCCESS",@"")],라고 생각합니다. 주 스레드를 제외한 모든 UIKit 클래스에 액세스해서는 안됩니다.

+0

안녕하세요 Eman, 그게 문제였습니다. 솔루션을 가져 주셔서 감사합니다. 죄송합니다. 나는 회신하지 못했습니다. – Krishnan

관련 문제