Iphone 从主线程或web线程以外的线程获取web锁
我正在制作一个需要与服务器(S3)通信的iPhone应用程序。但是,当我执行此代码时:Iphone 从主线程或web线程以外的线程获取web锁,iphone,ios,multithreading,uikit,webserver,Iphone,Ios,Multithreading,Uikit,Webserver,我正在制作一个需要与服务器(S3)通信的iPhone应用程序。但是,当我执行此代码时: - (void)submit { dispatch_queue_t Q = dispatch_queue_create("Formula Submit", NULL); dispatch_async(Q, ^{ NSMutableArray *formulas = [[NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"h
- (void)submit
{
dispatch_queue_t Q = dispatch_queue_create("Formula Submit", NULL);
dispatch_async(Q, ^{
NSMutableArray *formulas = [[NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"https://urlremoved.com"]] mutableCopy];
if (!formulas)
{
formulas = [[NSMutableArray alloc] init];
}
[_data addEntriesFromDictionary:[[NSDictionary alloc] initWithObjectsAndKeys:self.explanationTextView.text, @"explanation", nil]];
[formulas addObject:_data];
AmazonS3Client *s3 = [[AmazonS3Client alloc] initWithAccessKey:@"Access Key Removed" withSecretKey:@"Secret Key Removed"];
S3PutObjectRequest *por = [[S3PutObjectRequest alloc] initWithKey:@"File Name Removed" inBucket:@"Bucket Name Removed"];
por.contentType = @"application/octet-stream";
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:formulas format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
por.data = plistData;
[s3 putObject:por];
});
[self dismissModalViewControllerAnimated:YES];
}
我在控制台中收到以下错误/警告:
void _WebThreadLockFromAnyThread(bool), 0x20150be0: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
此消息似乎不会以任何方式影响应用程序性能。它成功地上传到S3,没有明显的问题
从本质上说,我想知道是否有办法让这个信息消失 访问下面的链接,它会让你知道这里没有UI操作。我认为下面的编码可以完成UI工作[self-dismissModalViewControllerAnimated:YES];是的,但它不在
dispatch\u async
块的范围内。