由于某种原因,我有一个dispatch_async线程,它崩溃,除非我有一个NSLog()方法在它前面执行.该块运行一个从数据库中检索用户名的方法.
崩溃:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:@"Author: %@",author]];
});
Run Code Online (Sandbox Code Playgroud)
工作:
NSLog(@"Fetching author for id: %@",author_string);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
user_web_communicator *usrWeb = [[user_web_communicator alloc]init];
NSString *author = [usrWeb getUsernameFromID:author_string];
[_author_label setText:[NSString stringWithFormat:@"Author: %@",author]];
});
Run Code Online (Sandbox Code Playgroud)
错误
Run Code Online (Sandbox Code Playgroud)2013-08-19 13:56:06.149 Poll Me[4995:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{行:AsyncImageView:0x827aa00.minX == 10 + 1*0x827b8d0.marker + -1*0x8281210.marker + 0.5*0x8281260.marker AsyncImageView:0x827aa00.minY == 27.5 + -1*0x827b910.marker + -1*0x82812a0. marker + 0.5*0x82812e0.marker + 0.5*0x82823f0.marker …