From fd3eb94fcb690cb03191e7a57290fd83e7e56354 Mon Sep 17 00:00:00 2001 From: Roy Marmelstein Date: Sun, 12 Jul 2015 21:35:42 +0200 Subject: [PATCH] Add main thread warnings and setter/getter assert --- AsyncDisplayKit/ASEditableTextNode.h | 5 ++++- AsyncDisplayKit/ASEditableTextNode.mm | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/ASEditableTextNode.h b/AsyncDisplayKit/ASEditableTextNode.h index 903fbbee43..c2b2060cdf 100644 --- a/AsyncDisplayKit/ASEditableTextNode.h +++ b/AsyncDisplayKit/ASEditableTextNode.h @@ -19,7 +19,10 @@ #pragma mark - Configuration -//! @abstract Access to underlying UITextView for more configuration options. +/** + @abstract Access to underlying UITextView for more configuration options. + @warning This property should only be used on the main thread and should not be accessed before the editable text node's view is created. + */ @property (nonatomic, readwrite, strong) UITextView *textView; //! @abstract The attributes to apply to new text being entered by the user. diff --git a/AsyncDisplayKit/ASEditableTextNode.mm b/AsyncDisplayKit/ASEditableTextNode.mm index 84e3cc1572..d4abfb6942 100644 --- a/AsyncDisplayKit/ASEditableTextNode.mm +++ b/AsyncDisplayKit/ASEditableTextNode.mm @@ -41,6 +41,7 @@ { @private // Configuration. + UITextView *_textView; NSDictionary *_typingAttributes; // Core. @@ -134,7 +135,7 @@ [self.view addSubview:_placeholderTextKitComponents.textView]; // Create and configure our text view. - _textKitComponents.textView = _textView; + _textKitComponents.textView = _textView; //_textKitComponents.textView = NO; // Unfortunately there's a bug here with iOS 7 DP5 that causes the text-view to only be one line high when scrollEnabled is NO. rdar://14729288 _textKitComponents.textView.delegate = self; _textKitComponents.textView.editable = YES; @@ -189,6 +190,21 @@ #pragma mark - Configuration @synthesize delegate = _delegate; +#pragma mark - +@dynamic textView; + +- (UITextView *)textView{ + ASDisplayNodeAssertMainThread(); + return _textView; +} + +- (void)setTextView:(UITextView *)textView +{ + ASDisplayNodeAssertMainThread(); + _textView = textView; +} + + #pragma mark - @dynamic typingAttributes;