From 88e83d3325b9dced0200e49f47b10c973c1e2eef Mon Sep 17 00:00:00 2001 From: LisonFan Date: Fri, 31 May 2024 10:53:38 +0800 Subject: [PATCH] Fix memory leak in UITextField caused by code in UILabel+AutomaticWriting + (void)load --- JKCategories/UIKit/UILable/UILabel+JKAutomaticWriting.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/JKCategories/UIKit/UILable/UILabel+JKAutomaticWriting.m b/JKCategories/UIKit/UILable/UILabel+JKAutomaticWriting.m index 18558cc3..10205a4d 100644 --- a/JKCategories/UIKit/UILable/UILabel+JKAutomaticWriting.m +++ b/JKCategories/UIKit/UILable/UILabel+JKAutomaticWriting.m @@ -36,11 +36,8 @@ @implementation UILabel (JKAutomaticWriting) + (void)load { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - jk_AutomaticWritingSwizzleSelector([self class], @selector(textRectForBounds:limitedToNumberOfLines:), @selector(jk_automaticWritingTextRectForBounds:limitedToNumberOfLines:)); - jk_AutomaticWritingSwizzleSelector([self class], @selector(drawTextInRect:), @selector(jk_drawAutomaticWritingTextInRect:)); - }); + jk_AutomaticWritingSwizzleSelector([self class], @selector(textRectForBounds:limitedToNumberOfLines:), @selector(jk_automaticWritingTextRectForBounds:limitedToNumberOfLines:)); + jk_AutomaticWritingSwizzleSelector([self class], @selector(drawTextInRect:), @selector(jk_drawAutomaticWritingTextInRect:)); } -(void)jk_drawAutomaticWritingTextInRect:(CGRect)rect