小编Edd*_*han的帖子

Obj-C:dispatch_async在没有NSLog的情况下崩溃

由于某种原因,我有一个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)

错误

2013-08-19 13:56:06.149 Poll Me[4995:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{
Run Code Online (Sandbox Code Playgroud)

行: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 …

crash asynchronous objective-c ios dispatch-async

1
推荐指数
1
解决办法
1631
查看次数

标签 统计

asynchronous ×1

crash ×1

dispatch-async ×1

ios ×1

objective-c ×1