Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created October 7, 2013 16:11
Show Gist options
  • Save odrobnik/6870496 to your computer and use it in GitHub Desktop.
Save odrobnik/6870496 to your computer and use it in GitHub Desktop.
- (id)initWithFrame:(CGRect)frame attributedString:(NSAttributedString *)attributedString
{
self = [super init];
if (self)
{
_synchQueue = dispatch_queue_create("DTMutableCoreTextLayoutFrame Sync Queue", DISPATCH_QUEUE_CONCURRENT);
}
return self;
}
- (void)dealloc
{
#if !OS_OBJECT_USE_OBJC
dispatch_release(_synchQueue);
#endif
}
- (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawingOptions)options
{
dispatch_sync(_synchQueue, ^{
[super drawInContext:context options:options];
});
}
- (void)replaceTextInRange:(NSRange)range withText:(NSAttributedString *)text dirtyRect:(CGRect *)dirtyRect
{
dispatch_barrier_sync(_synchQueue, ^{
// updates
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment