IOS

tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

지니 2017. 2. 6. 18:53
반응형

tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...




스레드 안에서 > 스레드 또 호출하거나 , 웹의 자바스크립트를 사용할려고 하니까 나왔다...


스레드에서 메소드를 콜 할땐,



[self performSelectorOnMainThread:@selector(CardUpdate) withObject:NULL waitUntilDone:YES];



-(void)CardUpdate{
     
    if(cardnum ==@"" || cardexpmon ==@"" || cardexpyear ==@""){
         
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"UnKown Card" delegate:nil cancelButtonTitle:@"확인" otherButtonTitles: nil];
        [alert show];
        NSString* script = [NSString stringWithFormat:@"cardupdate('%@', '%@','%@');", @"", @"",@""];
        [_MainWebView stringByEvaluatingJavaScriptFromString:script];
         
    }else{
     
        NSString* script = [NSString stringWithFormat:@"cardupdate('%@', '%@','%@');", cardnum, cardexpmon,cardexpyear];
        [_MainWebView stringByEvaluatingJavaScriptFromString:script];
    }
     
}



이런식으로 써워야 한다.


반응형