2014-11-22 108 views
0

我有一个问题,我希望你能帮助我。IOS NSMutableAttributedString崩溃EXC_BAD_ACCESS

我用​​在UILabel加载HTML,但所有的时间上

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 

    self.attrStr = [[NSMutableAttributedString alloc] initWithData:[desc dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; 
}); 

应用程序崩溃我尝试添加dispatch_async,但什么都没有改变。

所以请帮助我,

+0

无视回答我是不正确的,你可以为对象。就像我说过的,我不用太多 – 2014-11-22 09:12:42

+0

发布完整的堆栈跟踪。 – trojanfoe 2014-11-22 11:07:56

回答

0

您不能分配的块的属性。它可以在块中分配,但是当块离开堆或栈时,指针也是如此。

除非你当我离开我会做类似

__block BOOL myBool = NO; 
__block财产进入块

我知道想如果我要访问一个块中一个bool,并保持前值

然后在我的块中,我可以设置它 ^ {my_ool = YES; }

//myBool is YES now! 

这里给这个过一遍

[链接] https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html

+0

请您再解释一下吗? – Houssam 2014-11-22 08:01:39

+0

是啊给我几分钟,我将不得不查找如何做到这一点。我通常不会像块那样弄脏块 – 2014-11-22 08:03:44

+0

,我不得不去查看它,但是underbar underbar块告诉编译器在块退出后需要返回值 – 2014-11-22 08:07:29