未知警报void _WebThreadLockFromAnyThread(bool),

时间:2013-02-12 06:48:18

标签: iphone ios ipad

当我运行我的代码时,我的代码卡住并将日志记录为:

  

void _WebThreadLockFromAnyThread(bool),0x904db10:从主线程或Web线程以外的线程获取Web锁。不应该从辅助线程调用UIKit。

原因是什么,解决方法是什么?

我的代码:

-(IBAction)action:(id)sender{
    NSLog(@"HI");
    [self performSelectorInBackground:@selector(parse) withObject:nil];
}

-(void)parse{
    rssOutputData = [[NSMutableArray alloc]init];

 //[self performSelectorOnMainThread:@selector() withObject:nil waitUntilDone:NO];
        [NSThread detachNewThreadSelector: @selector(startIndicator) toTarget: self withObject: self];
     url=[[NSURL alloc]initWithString:[NSString stringWithFormat:@"http://service.technologyorg.com/service1/AuthenticateStudent=%@,%@,1",t1.text,t2.text]];
    NSLog(@"A%@",url);

    NSURLRequest *lRequest = [NSURLRequest requestWithURL:url
                                              cachePolicy:NSURLRequestUseProtocolCachePolicy
                                          timeoutInterval:30.0];
    NSURLResponse *response;
    NSError * error;
    //[NSURLConnection connectionWithRequest:lRequest delegate:self];
    [NSURLConnection sendSynchronousRequest:lRequest returningResponse:&response error:&error];
    NSLog(@"AB%@",response);
    if (nil == response) {
        NSLog(@"%@",error);
        [self performSelectorOnMainThread:@selector(updateTable) withObject:nil waitUntilDone:NO];
        UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"Connection failed!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }

    xmlData=[[NSMutableData alloc]initWithContentsOfURL:url];
    NSLog(@"B%@",xmlData);
    xmltitle=nil;
    xmlParserObject =[[NSXMLParser alloc]initWithData:xmlData];
    [xmlParserObject setDelegate:self];
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
    [xmlParserObject parse];
       dispatch_async(dispatch_get_main_queue(), ^{
    NSLog(@"XML:%@",xmllink);
    if ([xmltitle isEqualToString:@"true"]) {
        HomeViewController *lv=[[HomeViewController alloc]init];
        lv.s1=[[NSString alloc]initWithFormat:@"%@",xmllink];
        lv.s2=[[NSString alloc]initWithFormat:@"%@",xm1];
        myStaticPassword=[[NSString alloc]initWithFormat:@"%@",xm2];
        [self presentModalViewController:lv animated: YES];
        [self performSelectorOnMainThread:@selector(updateTable) withObject:nil waitUntilDone:NO];
    }else{
         [self performSelectorOnMainThread:@selector(updateTable) withObject:nil waitUntilDone:NO];
        UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"Incorrect Username/Password" message:@"Please check your Username or Password" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
        [alert show];
    }

       });
    });
}

0 个答案:

没有答案