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.
原因:在子线程中对UI进行了操作。
NSDate *startTime = [NSDate date];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSString *fetchedData = [self fetchSomethingFromServer];
NSString *processedData = [self processData:fetchedData];
NSString *firstResult = [self calculateFirstResult:processedData];
NSString *secondResult = [self calculateSecondResult:processedData];
NSString *resultsSummary = [NSString stringWithFormat:@"First: [%@]\nSecond: [%@]",
firstResult, secondResult];
dispatch_async(dispatch_get_main_queue(), ^{
[resultTextView setText:resultsSummary]; // *** 将UI操作放到主线程中执行 ***
});
NSDate *endTime = [NSDate date];
NSLog(@"Completed in %f seconds", [endTime timeIntervalSinceDate:startTime]);
});
分享到:
相关推荐
八年级英语下册 Unit 6 An old man tried to move the mountains(Section A 1a-2d)导学案(无答案)(新版)人教新目标版
Splitting a page in b+tree has to fix parent nodes and children so effectively will lock the tree for the duration, so parallel updates are very very difficult and have spawned a lot of research ...
Unit_6_An_old_man_tried_to_move_the_mountains.教学设计.docx
八年级英语下册 Unit 6 An old man tried to move the mountains Section A同步优化训练 (新版)人教新目标版
include the discovery process, which involves learning from other disciplines, and resource gathering, which encompasses mood boards, color palettes, and storyboards. Chapter 4: Form and Function Now ...
We are often asked if it is possible to run an UltraEdit macro or script on a file from the command line. The answer is yes - and it's not only possible, it's extremely simple! Using find/replace ...
one-term course, you should think of the book as a "buffet" or "smorgasbord" from which you can pick and choose the material that best supports the course you wish to teach. You should find it easy to...
Ajax melds together existing technologies to help ...Ajax is helping to redefine how we all should look at the Web, and I hope this book puts you on the path to defining your own Web 2.0 applications.
If you are a web or a full-stack JavaScript developer who have tried their hands on the traditional stacks like LAMP and wish to explore a new stack with modern web technologies then this book is for ...
We tried to offer paths from the standard knowledge of a student to modern and exciting topics in this way showing that a student from the first or second year is able to understand certain research ...
I have tried to create a circular command button like thing (using just shapes).
But that’s not all: more than ever before we’ve made sure to always explain which tool is best to use for which purpose, why that is the case, and how to avoid getting cut. We’ve made sure that ...
Here is a summary of the main changes: 1On the Web, this quote has been widely attributed to both Deming and Robert W. Hayden; however Professor Hayden told us that he can claim no credit for this ...
This is analogous to the situation where a layperson taking a first aid course could never claim to be a medical doctor or a nurse after taking that course. Becoming an AI expert requires that you ...
八年级英语下册 Unit 6 An old man tried to move the mountains(Section B 2a-2e)导学案(无答案)(新版)人教新目标版
The aim of this book, is to avoid you these problems: you do not need to write everything from scratch, ask on various forums or Usenet groups, or even read heaps of books just to make a simple ...
8.3 Adding Sound to the Weapons.......................................167 9. AI Manager 169 9.1 The AI State Control Script..........................................171 9.2 The Base AI Control Script....
【金榜学案】2014版八年级英语下册 Unit 6 An old man tried to move the mountains Section A课时作业 (新版)人教新目标版