Skip to content

Commit

Permalink
Move clearing out of ASTextKitComponents property delegates into ASTe…
Browse files Browse the repository at this point in the history
…xtKitComponents dealloc
  • Loading branch information
maicki committed Sep 27, 2017
1 parent 6c00897 commit c8c4dfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 0 additions & 7 deletions Source/ASEditableTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ - (instancetype)initWithTextKitComponents:(ASTextKitComponents *)textKitComponen
return self;
}

- (void)dealloc
{
_textKitComponents.textView.delegate = nil;
_textKitComponents.layoutManager.delegate = nil;
_placeholderTextKitComponents.layoutManager.delegate = nil;
}

#pragma mark - ASDisplayNode Overrides
- (void)didLoad
{
Expand Down
13 changes: 13 additions & 0 deletions Source/TextKit/ASTextKitComponents.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ @interface ASTextKitComponents ()

@implementation ASTextKitComponents

#pragma mark - Class

+ (instancetype)componentsWithAttributedSeedString:(NSAttributedString *)attributedSeedString
textContainerSize:(CGSize)textContainerSize
{
Expand Down Expand Up @@ -58,6 +60,17 @@ + (instancetype)componentsWithTextStorage:(NSTextStorage *)textStorage
return components;
}

#pragma mark - Lifecycle

- (void)dealloc
{
// Nil out all delegate to prevent crash
_textView.delegate = nil;
_layoutManager.delegate = nil;
}

#pragma mark - Sizing

- (CGSize)sizeForConstrainedWidth:(CGFloat)constrainedWidth
{
ASTextKitComponents *components = self;
Expand Down

0 comments on commit c8c4dfe

Please sign in to comment.