从主线程或Web线程以外的线程获取Web锁定

时间:2012-12-26 16:17:29

标签: iphone ios multithreading uikit webserver

我正在制作一款需要与服务器通信的iPhone应用程序(S3)。但是,当我执行此代码时:

- (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,没有明显的问题。

我很想知道,如果有办法让这条消息消失

0 个答案:

没有答案