[ASTextKitComponents] Make sure Main Thread Checker isn't triggered during background calculations #trivial (#612)

* Add unit test

* Make sure TextKit components can calculate size in background without upsetting Main Thread Checker
- Add a new thread-safe text view bounds.
- Temporary components stack doesn't have a text view so it can be safely deallocated off main.

* Add ASTextKitComponentsTextView

* Remove unnecessary change

* Fix minor mistake

* ASTextKitComponentsTextView has only 1 initializer

* Minor change

* Switch to atomic property

* Remove manual synthesization
This commit is contained in:
Huy Nguyen
2017-10-17 14:20:20 +01:00
committed by GitHub
parent 1e7d46196f
commit c12509e67a
4 changed files with 71 additions and 19 deletions

View File

@@ -20,6 +20,12 @@
NS_ASSUME_NONNULL_BEGIN
@interface ASTextKitComponentsTextView : UITextView
- (instancetype)initWithFrame:(CGRect)frame textContainer:(nullable NSTextContainer *)textContainer NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder __unavailable;
- (instancetype)init __unavailable;
@end
AS_SUBCLASSING_RESTRICTED
@interface ASTextKitComponents : NSObject
@@ -52,14 +58,13 @@ AS_SUBCLASSING_RESTRICTED
*/
- (CGSize)sizeForConstrainedWidth:(CGFloat)constrainedWidth;
- (CGSize)sizeForConstrainedWidth:(CGFloat)constrainedWidth
forMaxNumberOfLines:(NSInteger)numberOfLines;
@property (nonatomic, strong, readonly) NSTextStorage *textStorage;
@property (nonatomic, strong, readonly) NSTextContainer *textContainer;
@property (nonatomic, strong, readonly) NSLayoutManager *layoutManager;
@property (nonatomic, strong, nullable) UITextView *textView;
@property (nonatomic, strong, nullable) ASTextKitComponentsTextView *textView;
@end