Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 未知警报无效\u WebThreadLockFromAnyThread(bool),_Iphone_Ios_Ipad - Fatal编程技术网

Iphone 未知警报无效\u WebThreadLockFromAnyThread(bool),

Iphone 未知警报无效\u WebThreadLockFromAnyThread(bool),,iphone,ios,ipad,Iphone,Ios,Ipad,当我运行我的代码时,我的代码被卡住,并以以下方式给出日志: void\u WebThreadLockFromAnyThread(bool),0x904db10:从主线程或web线程以外的线程获取web锁。不应从次线程调用UIKit 原因是什么,解决办法是什么 我的代码: -(IBAction)action:(id)sender{ NSLog(@"HI"); [self performSelectorInBackground:@selector(parse) withObject:

当我运行我的代码时,我的代码被卡住,并以以下方式给出日志:

void\u 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];
    }

       });
    });
}

原因:您正在从后台线程调用UIKit。解决方案:不要这样做。请仔细检查我的代码和我遗漏的地方。你正在创建IDK。有多少后台线程,你在视图控制器和其他UI上操作。你应该只在主线程上这样做。检查我的答案并在主线程上显示你的警告视图。。。