I have a problem that I hope that you can help me.
I use NSMutatableAttributedString
to load html in UILabel
but all time the application crash on
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];
});
I tried to add dispatch_async
but nothing changed.
So Please help me,
You cannot assign a property in a block. It can be assigned in the block, but when the block leaves the heap or stack so does the pointer.
unless you do __block before the property goes into the block
I know like if I want to access a bool inside a block and keep the value when i exit I would do something like
then in my block I could set it ^{ myBool = YES; }
here give this a once over
[a link]https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html