ibireme 9 жил өмнө
parent
commit
9b9dd84dda

+ 10 - 6
YYText/Component/YYTextContainerView.h

@@ -17,6 +17,8 @@
 #import "YYTextLayout.h"
 #import "YYTextLayout.h"
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A simple view to diaplay `YYTextLayout`.
  A simple view to diaplay `YYTextLayout`.
 
 
@@ -29,23 +31,25 @@
 @interface YYTextContainerView : UIView
 @interface YYTextContainerView : UIView
 
 
 /// First responder's aciton will forward to this view.
 /// First responder's aciton will forward to this view.
-@property (nonatomic, weak) UIView *hostView;
+@property (nullable, nonatomic, weak) UIView *hostView;
 
 
 /// Debug option for layout debug. Set this property will let the view redraw it's contents.
 /// Debug option for layout debug. Set this property will let the view redraw it's contents.
-@property (nonatomic, copy) YYTextDebugOption *debugOption;
+@property (nullable, nonatomic, copy) YYTextDebugOption *debugOption;
 
 
 /// Text vertical alignment.
 /// Text vertical alignment.
-@property (nonatomic, assign) YYTextVerticalAlignment textVerticalAlignment;
+@property (nonatomic) YYTextVerticalAlignment textVerticalAlignment;
 
 
 /// Text layout. Set this property will let the view redraw it's contents.
 /// Text layout. Set this property will let the view redraw it's contents.
-@property (nonatomic, strong) YYTextLayout *layout;
+@property (nullable, nonatomic, strong) YYTextLayout *layout;
 
 
 /// The contents fade animation duration when the layout's contents changed. Default is 0 (no animation).
 /// The contents fade animation duration when the layout's contents changed. Default is 0 (no animation).
-@property (nonatomic, assign) NSTimeInterval contentsFadeDuration;
+@property (nonatomic) NSTimeInterval contentsFadeDuration;
 
 
 /// Convenience method to set `layout` and `contentsFadeDuration`.
 /// Convenience method to set `layout` and `contentsFadeDuration`.
 /// @param layout  Same as `layout` property.
 /// @param layout  Same as `layout` property.
 /// @param fadeDuration  Same as `contentsFadeDuration` property.
 /// @param fadeDuration  Same as `contentsFadeDuration` property.
-- (void)setLayout:(YYTextLayout *)layout withFadeDuration:(NSTimeInterval)fadeDuration;
+- (void)setLayout:(nullable YYTextLayout *)layout withFadeDuration:(NSTimeInterval)fadeDuration;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 18 - 14
YYText/Component/YYTextDebugOption.h

@@ -13,6 +13,8 @@
 
 
 @class YYTextDebugOption;
 @class YYTextDebugOption;
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  The YYTextDebugTarget protocol defines the method a debug target should implement.
  The YYTextDebugTarget protocol defines the method a debug target should implement.
  A debug target can be add to the global container to receive the shared debug
  A debug target can be add to the global container to receive the shared debug
@@ -28,7 +30,7 @@
  
  
  @param option  The shared debug option.
  @param option  The shared debug option.
  */
  */
-- (void)setDebugOption:(YYTextDebugOption *)option;
+- (void)setDebugOption:(nullable YYTextDebugOption *)option;
 @end
 @end
 
 
 
 
@@ -37,17 +39,17 @@
  The debug option for YYText.
  The debug option for YYText.
  */
  */
 @interface YYTextDebugOption : NSObject <NSCopying>
 @interface YYTextDebugOption : NSObject <NSCopying>
-@property (nonatomic, strong) UIColor *baselineColor;      ///< baseline color
-@property (nonatomic, strong) UIColor *CTFrameBorderColor; ///< CTFrame path border color
-@property (nonatomic, strong) UIColor *CTFrameFillColor;   ///< CTFrame path fill color
-@property (nonatomic, strong) UIColor *CTLineBorderColor;  ///< CTLine bounds border color
-@property (nonatomic, strong) UIColor *CTLineFillColor;    ///< CTLine bounds fill color
-@property (nonatomic, strong) UIColor *CTLineNumberColor;  ///< CTLine line number color
-@property (nonatomic, strong) UIColor *CTRunBorderColor;   ///< CTRun bounds border color
-@property (nonatomic, strong) UIColor *CTRunFillColor;     ///< CTRun bounds fill color
-@property (nonatomic, strong) UIColor *CTRunNumberColor;   ///< CTRun number color
-@property (nonatomic, strong) UIColor *CGGlyphBorderColor; ///< CGGlyph bounds border color
-@property (nonatomic, strong) UIColor *CGGlyphFillColor;   ///< CGGlyph bounds fill color
+@property (nullable, nonatomic, strong) UIColor *baselineColor;      ///< baseline color
+@property (nullable, nonatomic, strong) UIColor *CTFrameBorderColor; ///< CTFrame path border color
+@property (nullable, nonatomic, strong) UIColor *CTFrameFillColor;   ///< CTFrame path fill color
+@property (nullable, nonatomic, strong) UIColor *CTLineBorderColor;  ///< CTLine bounds border color
+@property (nullable, nonatomic, strong) UIColor *CTLineFillColor;    ///< CTLine bounds fill color
+@property (nullable, nonatomic, strong) UIColor *CTLineNumberColor;  ///< CTLine line number color
+@property (nullable, nonatomic, strong) UIColor *CTRunBorderColor;   ///< CTRun bounds border color
+@property (nullable, nonatomic, strong) UIColor *CTRunFillColor;     ///< CTRun bounds fill color
+@property (nullable, nonatomic, strong) UIColor *CTRunNumberColor;   ///< CTRun number color
+@property (nullable, nonatomic, strong) UIColor *CGGlyphBorderColor; ///< CGGlyph bounds border color
+@property (nullable, nonatomic, strong) UIColor *CGGlyphFillColor;   ///< CGGlyph bounds fill color
 
 
 - (BOOL)needDrawDebug; ///< `YES`: at least one debug color is visible. `NO`: all debug color is invisible/nil.
 - (BOOL)needDrawDebug; ///< `YES`: at least one debug color is visible. `NO`: all debug color is invisible/nil.
 - (void)clear; ///< Set all debug color to nil.
 - (void)clear; ///< Set all debug color to nil.
@@ -75,7 +77,7 @@
  
  
  @return The shared debug option, default is nil.
  @return The shared debug option, default is nil.
  */
  */
-+ (YYTextDebugOption *)sharedDebugOption;
++ (nullable YYTextDebugOption *)sharedDebugOption;
 
 
 /**
 /**
  Set a debug option as shared debug option.
  Set a debug option as shared debug option.
@@ -86,6 +88,8 @@
  
  
  @param option  A new debug option (nil is valid).
  @param option  A new debug option (nil is valid).
  */
  */
-+ (void)setSharedDebugOption:(YYTextDebugOption *)option;
++ (void)setSharedDebugOption:(nullable YYTextDebugOption *)option;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
YYText/Component/YYTextEffectWindow.h

@@ -19,6 +19,8 @@
 #import "YYTextSelectionView.h"
 #import "YYTextSelectionView.h"
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A window to display magnifier and extra contents for text view.
  A window to display magnifier and extra contents for text view.
  
  
@@ -28,7 +30,7 @@
 @interface YYTextEffectWindow : UIWindow
 @interface YYTextEffectWindow : UIWindow
 
 
 /// Returns the shared instance (returns nil in App Extension).
 /// Returns the shared instance (returns nil in App Extension).
-+ (instancetype)sharedWindow;
++ (nullable instancetype)sharedWindow;
 
 
 /// Show the magnifier in this window with a 'popup' animation. @param mag A magnifier.
 /// Show the magnifier in this window with a 'popup' animation. @param mag A magnifier.
 - (void)showMagnifier:(YYTextMagnifier *)mag;
 - (void)showMagnifier:(YYTextMagnifier *)mag;
@@ -46,3 +48,5 @@
 - (void)hideSelectionDot:(YYTextSelectionView *)selection;
 - (void)hideSelectionDot:(YYTextSelectionView *)selection;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
YYText/Component/YYTextInput.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Text position affinity. For example, the offset appears after the last
  Text position affinity. For example, the offset appears after the last
  character on a line is backward affinity, before the first character on
  character on a line is backward affinity, before the first character on
@@ -81,3 +83,5 @@ typedef NS_ENUM(NSInteger, YYTextAffinity) {
 @property (nonatomic, readwrite) BOOL isVertical;
 @property (nonatomic, readwrite) BOOL isVertical;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 8 - 4
YYText/Component/YYTextKeyboardManager.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  System keyboard transition information.
  System keyboard transition information.
  Use -[YYTextKeyboardManager convertRect:toView:] to convert frame to specified view.
  Use -[YYTextKeyboardManager convertRect:toView:] to convert frame to specified view.
@@ -49,13 +51,13 @@ typedef struct {
 + (instancetype)new UNAVAILABLE_ATTRIBUTE;
 + (instancetype)new UNAVAILABLE_ATTRIBUTE;
 
 
 /// Get the default manager (returns nil in App Extension).
 /// Get the default manager (returns nil in App Extension).
-+ (instancetype)defaultManager;
++ (nullable instancetype)defaultManager;
 
 
 /// Get the keyboard window. nil if there's no keyboard window.
 /// Get the keyboard window. nil if there's no keyboard window.
-@property (nonatomic, readonly) UIWindow *keyboardWindow;
+@property (nullable, nonatomic, readonly) UIWindow *keyboardWindow;
 
 
 /// Get the keyboard view. nil if there's no keyboard view.
 /// Get the keyboard view. nil if there's no keyboard view.
-@property (nonatomic, readonly) UIView *keyboardView;
+@property (nullable, nonatomic, readonly) UIView *keyboardView;
 
 
 /// Whether the keyboard is visible.
 /// Whether the keyboard is visible.
 @property (nonatomic, readonly, getter=isKeyboardVisible) BOOL keyboardVisible;
 @property (nonatomic, readonly, getter=isKeyboardVisible) BOOL keyboardVisible;
@@ -89,6 +91,8 @@ typedef struct {
  @param view A specified view or window (pass nil to convert for main window).
  @param view A specified view or window (pass nil to convert for main window).
  @return The converted rect in specifeid view.
  @return The converted rect in specifeid view.
  */
  */
-- (CGRect)convertRect:(CGRect)rect toView:(UIView *)view;
+- (CGRect)convertRect:(CGRect)rect toView:(nullable UIView *)view;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 99 - 63
YYText/Component/YYTextLayout.h

@@ -23,6 +23,12 @@
 #endif
 #endif
 
 
 @protocol YYTextLinePositionModifier;
 @protocol YYTextLinePositionModifier;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The max text container size in layout.
+ */
 extern const CGSize YYTextContainerMaxSize;
 extern const CGSize YYTextContainerMaxSize;
 
 
 /**
 /**
@@ -59,43 +65,43 @@ extern const CGSize YYTextContainerMaxSize;
 + (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets;
 + (instancetype)containerWithSize:(CGSize)size insets:(UIEdgeInsets)insets;
 
 
 /// Creates a container with the specified path. @param size The path.
 /// Creates a container with the specified path. @param size The path.
-+ (instancetype)containerWithPath:(UIBezierPath *)path;
++ (instancetype)containerWithPath:(nullable UIBezierPath *)path;
 
 
 /// The constrained size. (if the size is larger than YYTextContainerMaxSize, it will be clipped)
 /// The constrained size. (if the size is larger than YYTextContainerMaxSize, it will be clipped)
-@property (assign) CGSize size;
+@property CGSize size;
 
 
 /// The insets for constrained size. The inset value should not be negative. Default is UIEdgeInsetsZero.
 /// The insets for constrained size. The inset value should not be negative. Default is UIEdgeInsetsZero.
-@property (assign) UIEdgeInsets insets;
+@property UIEdgeInsets insets;
 
 
 /// Custom constrained path. Set this property to ignore `size` and `insets`. Default is nil.
 /// Custom constrained path. Set this property to ignore `size` and `insets`. Default is nil.
-@property (copy) UIBezierPath *path;
+@property (nullable, copy) UIBezierPath *path;
 
 
 /// An array of `UIBezierPath` for path exclusion. Default is nil.
 /// An array of `UIBezierPath` for path exclusion. Default is nil.
-@property (copy) NSArray *exclusionPaths;
+@property (nullable, copy) NSArray<UIBezierPath *> *exclusionPaths;
 
 
 /// Path line width. Default is 0;
 /// Path line width. Default is 0;
-@property (assign) CGFloat pathLineWidth;
+@property CGFloat pathLineWidth;
 
 
 /// YES:(PathFillEvenOdd) Text is filled in the area that would be painted if the path were given to CGContextEOFillPath.
 /// YES:(PathFillEvenOdd) Text is filled in the area that would be painted if the path were given to CGContextEOFillPath.
 /// NO: (PathFillWindingNumber) Text is fill in the area that would be painted if the path were given to CGContextFillPath.
 /// NO: (PathFillWindingNumber) Text is fill in the area that would be painted if the path were given to CGContextFillPath.
 /// Default is YES;
 /// Default is YES;
-@property (assign, getter=isPathFillEvenOdd) BOOL pathFillEvenOdd;
+@property (getter=isPathFillEvenOdd) BOOL pathFillEvenOdd;
 
 
 /// Whether the text is vertical form (may used for CJK text layout). Default is NO.
 /// Whether the text is vertical form (may used for CJK text layout). Default is NO.
-@property (assign, getter=isVerticalForm) BOOL verticalForm;
+@property (getter=isVerticalForm) BOOL verticalForm;
 
 
 /// Maximum number of rows, 0 means no limit. Default is 0.
 /// Maximum number of rows, 0 means no limit. Default is 0.
-@property (assign) NSUInteger maximumNumberOfRows;
+@property NSUInteger maximumNumberOfRows;
 
 
 /// The line truncation type, default is none.
 /// The line truncation type, default is none.
-@property (assign) YYTextTruncationType truncationType;
+@property YYTextTruncationType truncationType;
 
 
 /// The truncation token. If nil, the layout will use "…" instead. Default is nil.
 /// The truncation token. If nil, the layout will use "…" instead. Default is nil.
-@property (copy) NSAttributedString *truncationToken;
+@property (nullable, copy) NSAttributedString *truncationToken;
 
 
 /// This modifier is applied to the lines before the layout is completed,
 /// This modifier is applied to the lines before the layout is completed,
 /// give you a chance to modify the line position. Default is nil.
 /// give you a chance to modify the line position. Default is nil.
-@property (copy) id<YYTextLinePositionModifier> linePositionModifier;
+@property (nullable, copy) id<YYTextLinePositionModifier> linePositionModifier;
 @end
 @end
 
 
 
 
@@ -111,7 +117,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param text      The full text.
  @param text      The full text.
  @param container The layout container.
  @param container The layout container.
  */
  */
-- (void)modifyLines:(NSArray *)lines fromText:(NSAttributedString *)text inContainer:(YYTextContainer *)container;
+- (void)modifyLines:(NSArray<YYTextLine *> *)lines fromText:(NSAttributedString *)text inContainer:(YYTextContainer *)container;
 @end
 @end
 
 
 
 
@@ -157,7 +163,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param text The text (if nil, returns nil).
  @param text The text (if nil, returns nil).
  @return A new layout, or nil when an error occurs.
  @return A new layout, or nil when an error occurs.
 */
 */
-+ (YYTextLayout *)layoutWithContainerSize:(CGSize)size text:(NSAttributedString *)text;
++ (nullable YYTextLayout *)layoutWithContainerSize:(CGSize)size text:(NSAttributedString *)text;
 
 
 /**
 /**
  Generate a layout with the given container and text.
  Generate a layout with the given container and text.
@@ -166,7 +172,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param text      The text (if nil, returns nil).
  @param text      The text (if nil, returns nil).
  @return A new layout, or nil when an error occurs.
  @return A new layout, or nil when an error occurs.
  */
  */
-+ (YYTextLayout *)layoutWithContainer:(YYTextContainer *)container text:(NSAttributedString *)text;
++ (nullable YYTextLayout *)layoutWithContainer:(YYTextContainer *)container text:(NSAttributedString *)text;
 
 
 /**
 /**
  Generate a layout with the given container and text.
  Generate a layout with the given container and text.
@@ -177,7 +183,7 @@ extern const CGSize YYTextContainerMaxSize;
     length of the range is 0, it means the length is no limit.
     length of the range is 0, it means the length is no limit.
  @return A new layout, or nil when an error occurs.
  @return A new layout, or nil when an error occurs.
  */
  */
-+ (YYTextLayout *)layoutWithContainer:(YYTextContainer *)container text:(NSAttributedString *)text range:(NSRange)range;
++ (nullable YYTextLayout *)layoutWithContainer:(YYTextContainer *)container text:(NSAttributedString *)text range:(NSRange)range;
 
 
 /**
 /**
  Generate layouts with the given containers and text.
  Generate layouts with the given containers and text.
@@ -187,7 +193,8 @@ extern const CGSize YYTextContainerMaxSize;
  @return An array of YYTextLayout object (the count is same as containers),
  @return An array of YYTextLayout object (the count is same as containers),
     or nil when an error occurs.
     or nil when an error occurs.
  */
  */
-+ (NSArray *)layoutWithContainers:(NSArray *)containers text:(NSAttributedString *)text;
++ (nullable NSArray<YYTextLayout *> *)layoutWithContainers:(NSArray<YYTextContainer *> *)containers
+                                                      text:(NSAttributedString *)text;
 
 
 /**
 /**
  Generate layouts with the given containers and text.
  Generate layouts with the given containers and text.
@@ -199,7 +206,9 @@ extern const CGSize YYTextContainerMaxSize;
  @return An array of YYTextLayout object (the count is same as containers),
  @return An array of YYTextLayout object (the count is same as containers),
     or nil when an error occurs.
     or nil when an error occurs.
  */
  */
-+ (NSArray *)layoutWithContainers:(NSArray *)containers text:(NSAttributedString *)text range:(NSRange)range;
++ (nullable NSArray<YYTextLayout *> *)layoutWithContainers:(NSArray<YYTextContainer *> *)containers
+                                                      text:(NSAttributedString *)text
+                                                     range:(NSRange)range;
 
 
 - (instancetype)init UNAVAILABLE_ATTRIBUTE;
 - (instancetype)init UNAVAILABLE_ATTRIBUTE;
 + (instancetype)new UNAVAILABLE_ATTRIBUTE;
 + (instancetype)new UNAVAILABLE_ATTRIBUTE;
@@ -210,31 +219,56 @@ extern const CGSize YYTextContainerMaxSize;
 /// @name Text layout attributes
 /// @name Text layout attributes
 ///=============================================================================
 ///=============================================================================
 
 
-@property (nonatomic, readonly) YYTextContainer *container;    ///< The text container
-@property (nonatomic, readonly) NSAttributedString *text;      ///< The full text
-@property (nonatomic, readonly) NSRange range;                 ///< The text range in full text
-@property (nonatomic, readonly) CTFramesetterRef frameSetter;  ///< CTFrameSetter
-@property (nonatomic, readonly) CTFrameRef frame;              ///< CTFrame
-@property (nonatomic, readonly) NSArray *lines;                ///< Array of `YYTextLine`, no truncated
-@property (nonatomic, readonly) YYTextLine *truncatedLine;     ///< YYTextLine with truncated token, or nil
-@property (nonatomic, readonly) NSArray *attachments;          ///< Array of `YYTextAttachment`
-@property (nonatomic, readonly) NSArray *attachmentRanges;     ///< Array of NSRange(wrapped by NSValue) in text
-@property (nonatomic, readonly) NSArray *attachmentRects;      ///< Array of CGRect(wrapped by NSValue) in container
-@property (nonatomic, readonly) NSSet *attachmentContentsSet;  ///< Set of Attachment (UIImage/UIView/CALayer)
-@property (nonatomic, readonly) NSUInteger rowCount;           ///< Number of rows
-@property (nonatomic, readonly) NSRange visibleRange;          ///< Visible text range
-@property (nonatomic, readonly) CGRect textBoundingRect;       ///< Bounding rect (glyphs)
-@property (nonatomic, readonly) CGSize textBoundingSize;       ///< Bounding size (glyphs and insets, ceil to pixel)
-@property (nonatomic, readonly) BOOL containsHighlight;        ///< Has highlight attribute
-@property (nonatomic, readonly) BOOL needDrawBlockBorder;      ///< Has block border attribute
-@property (nonatomic, readonly) BOOL needDrawBackgroundBorder; ///< Has background border attribute
-@property (nonatomic, readonly) BOOL needDrawShadow;           ///< Has shadow attribute
-@property (nonatomic, readonly) BOOL needDrawUnderline;        ///< Has underline attribute
-@property (nonatomic, readonly) BOOL needDrawText;             ///< Has visible text
-@property (nonatomic, readonly) BOOL needDrawAttachment;       ///< Has attachment attribute
-@property (nonatomic, readonly) BOOL needDrawInnerShadow;      ///< Has inner shadow attribute
-@property (nonatomic, readonly) BOOL needDrawStrikethrough;    ///< Has strickthrough attribute
-@property (nonatomic, readonly) BOOL needDrawBorder;           ///< Has border attribute
+///< The text container
+@property (nonatomic, strong, readonly) YYTextContainer *container;
+///< The full text
+@property (nonatomic, strong, readonly) NSAttributedString *text;
+///< The text range in full text
+@property (nonatomic, readonly) NSRange range;
+///< CTFrameSetter
+@property (nonatomic, readonly) CTFramesetterRef frameSetter;
+///< CTFrame
+@property (nonatomic, readonly) CTFrameRef frame;
+///< Array of `YYTextLine`, no truncated
+@property (nonatomic, strong, readonly) NSArray<YYTextLine *> *lines;
+///< YYTextLine with truncated token, or nil
+@property (nullable, nonatomic, strong, readonly) YYTextLine *truncatedLine;
+///< Array of `YYTextAttachment`
+@property (nullable, nonatomic, strong, readonly) NSArray<YYTextAttachment *> *attachments;
+///< Array of NSRange(wrapped by NSValue) in text
+@property (nullable, nonatomic, strong, readonly) NSArray<NSValue *> *attachmentRanges;
+///< Array of CGRect(wrapped by NSValue) in container
+@property (nullable, nonatomic, strong, readonly) NSArray<NSValue *> *attachmentRects;
+///< Set of Attachment (UIImage/UIView/CALayer)
+@property (nullable, nonatomic, strong, readonly) NSSet *attachmentContentsSet;
+///< Number of rows
+@property (nonatomic, readonly) NSUInteger rowCount;
+///< Visible text range
+@property (nonatomic, readonly) NSRange visibleRange;
+///< Bounding rect (glyphs)
+@property (nonatomic, readonly) CGRect textBoundingRect;
+///< Bounding size (glyphs and insets, ceil to pixel)
+@property (nonatomic, readonly) CGSize textBoundingSize;
+///< Has highlight attribute
+@property (nonatomic, readonly) BOOL containsHighlight;
+///< Has block border attribute
+@property (nonatomic, readonly) BOOL needDrawBlockBorder;
+///< Has background border attribute
+@property (nonatomic, readonly) BOOL needDrawBackgroundBorder;
+///< Has shadow attribute
+@property (nonatomic, readonly) BOOL needDrawShadow;
+///< Has underline attribute
+@property (nonatomic, readonly) BOOL needDrawUnderline;
+///< Has visible text
+@property (nonatomic, readonly) BOOL needDrawText;
+///< Has attachment attribute
+@property (nonatomic, readonly) BOOL needDrawAttachment;
+///< Has inner shadow attribute
+@property (nonatomic, readonly) BOOL needDrawInnerShadow;
+///< Has strickthrough attribute
+@property (nonatomic, readonly) BOOL needDrawStrikethrough;
+///< Has border attribute
+@property (nonatomic, readonly) BOOL needDrawBorder;
 
 
 
 
 #pragma mark - Query information from text layout
 #pragma mark - Query information from text layout
@@ -318,7 +352,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param point  A point in the container.
  @param point  A point in the container.
  @return A text position, or nil if not found.
  @return A text position, or nil if not found.
  */
  */
-- (YYTextPosition *)closestPositionToPoint:(CGPoint)point;
+- (nullable YYTextPosition *)closestPositionToPoint:(CGPoint)point;
 
 
 /**
 /**
  Returns the new position when moving selection grabber in text view.
  Returns the new position when moving selection grabber in text view.
@@ -332,9 +366,9 @@ extern const CGSize YYTextContainerMaxSize;
  
  
  @return A text position, or nil if not found.
  @return A text position, or nil if not found.
  */
  */
-- (YYTextPosition *)positionForPoint:(CGPoint)point
-                         oldPosition:(YYTextPosition *)oldPosition
-                       otherPosition:(YYTextPosition *)otherPosition;
+- (nullable YYTextPosition *)positionForPoint:(CGPoint)point
+                                  oldPosition:(YYTextPosition *)oldPosition
+                                otherPosition:(YYTextPosition *)otherPosition;
 
 
 /**
 /**
  Returns the character or range of characters that is at a given point in the container.
  Returns the character or range of characters that is at a given point in the container.
@@ -347,7 +381,7 @@ extern const CGSize YYTextContainerMaxSize;
  @return An object representing a range that encloses a character (or characters) 
  @return An object representing a range that encloses a character (or characters) 
  at point. Or nil if not found.
  at point. Or nil if not found.
  */
  */
-- (YYTextRange *)textRangeAtPoint:(CGPoint)point;
+- (nullable YYTextRange *)textRangeAtPoint:(CGPoint)point;
 
 
 /**
 /**
  Returns the closest character or range of characters that is at a given point in 
  Returns the closest character or range of characters that is at a given point in 
@@ -360,7 +394,7 @@ extern const CGSize YYTextContainerMaxSize;
  @return An object representing a range that encloses a character (or characters)
  @return An object representing a range that encloses a character (or characters)
  at point. Or nil if not found.
  at point. Or nil if not found.
  */
  */
-- (YYTextRange *)closestTextRangeAtPoint:(CGPoint)point;
+- (nullable YYTextRange *)closestTextRangeAtPoint:(CGPoint)point;
 
 
 /**
 /**
  If the position is inside an emoji, composed character sequences, line break '\\r\\n'
  If the position is inside an emoji, composed character sequences, line break '\\r\\n'
@@ -371,7 +405,7 @@ extern const CGSize YYTextContainerMaxSize;
  
  
  @return A text-range object that extend the position. Or nil if an error occurs
  @return A text-range object that extend the position. Or nil if an error occurs
  */
  */
-- (YYTextRange *)textRangeByExtendingPosition:(YYTextPosition *)position;
+- (nullable YYTextRange *)textRangeByExtendingPosition:(YYTextPosition *)position;
 
 
 /**
 /**
  Returns a text range at a given offset in a specified direction from another 
  Returns a text range at a given offset in a specified direction from another 
@@ -384,9 +418,9 @@ extern const CGSize YYTextContainerMaxSize;
  @return A text-range object that represents the distance from position to the
  @return A text-range object that represents the distance from position to the
  farthest extent in direction. Or nil if an error occurs.
  farthest extent in direction. Or nil if an error occurs.
  */
  */
-- (YYTextRange *)textRangeByExtendingPosition:(YYTextPosition *)position
-                                  inDirection:(UITextLayoutDirection)direction
-                                       offset:(NSInteger)offset;
+- (nullable YYTextRange *)textRangeByExtendingPosition:(YYTextPosition *)position
+                                           inDirection:(UITextLayoutDirection)direction
+                                                offset:(NSInteger)offset;
 
 
 /**
 /**
  Returns the line index for a given text position.
  Returns the line index for a given text position.
@@ -446,7 +480,7 @@ extern const CGSize YYTextContainerMaxSize;
  @return An array of `YYTextSelectionRect` objects that encompass the selection.
  @return An array of `YYTextSelectionRect` objects that encompass the selection.
  If not found, the array is empty.
  If not found, the array is empty.
  */
  */
-- (NSArray *)selectionRectsForRange:(YYTextRange *)range;
+- (NSArray<YYTextSelectionRect *> *)selectionRectsForRange:(YYTextRange *)range;
 
 
 /**
 /**
  Returns an array of selection rects corresponding to the range of text.
  Returns an array of selection rects corresponding to the range of text.
@@ -455,7 +489,7 @@ extern const CGSize YYTextContainerMaxSize;
  @return An array of `YYTextSelectionRect` objects that encompass the selection.
  @return An array of `YYTextSelectionRect` objects that encompass the selection.
  If not found, the array is empty.
  If not found, the array is empty.
  */
  */
-- (NSArray *)selectionRectsWithoutStartAndEndForRange:(YYTextRange *)range;
+- (NSArray<YYTextSelectionRect *> *)selectionRectsWithoutStartAndEndForRange:(YYTextRange *)range;
 
 
 /**
 /**
  Returns the start and end selection rects corresponding to the range of text.
  Returns the start and end selection rects corresponding to the range of text.
@@ -465,7 +499,7 @@ extern const CGSize YYTextContainerMaxSize;
  @return An array of `YYTextSelectionRect` objects contains the start and end to
  @return An array of `YYTextSelectionRect` objects contains the start and end to
  the selection. If not found, the array is empty.
  the selection. If not found, the array is empty.
  */
  */
-- (NSArray *)selectionRectsWithOnlyStartAndEndForRange:(YYTextRange *)range;
+- (NSArray<YYTextSelectionRect *> *)selectionRectsWithOnlyStartAndEndForRange:(YYTextRange *)range;
 
 
 
 
 #pragma mark - Draw text layout
 #pragma mark - Draw text layout
@@ -494,13 +528,13 @@ extern const CGSize YYTextContainerMaxSize;
                     If it returns YES, the further draw progress will be canceled.
                     If it returns YES, the further draw progress will be canceled.
                     Pass nil to ignore this feature.
                     Pass nil to ignore this feature.
  */
  */
-- (void)drawInContext:(CGContextRef)context
+- (void)drawInContext:(nullable CGContextRef)context
                  size:(CGSize)size
                  size:(CGSize)size
                 point:(CGPoint)point
                 point:(CGPoint)point
-                 view:(UIView *)view
-                layer:(CALayer *)layer
-                debug:(YYTextDebugOption *)debug
-               cancel:(BOOL (^)(void))cancel;
+                 view:(nullable UIView *)view
+                layer:(nullable CALayer *)layer
+                debug:(nullable YYTextDebugOption *)debug
+               cancel:(nullable BOOL (^)(void))cancel;
 
 
 /**
 /**
  Draw the layout text and image (without view or layer attachments).
  Draw the layout text and image (without view or layer attachments).
@@ -511,7 +545,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param size    The context size.
  @param size    The context size.
  @param debug   The debug option. Pass nil to avoid debug drawing.
  @param debug   The debug option. Pass nil to avoid debug drawing.
  */
  */
-- (void)drawInContext:(CGContextRef)context size:(CGSize)size debug:(YYTextDebugOption *)debug;
+- (void)drawInContext:(nullable CGContextRef)context size:(CGSize)size debug:(nullable YYTextDebugOption *)debug;
 
 
 /**
 /**
  Show view and layer attachments.
  Show view and layer attachments.
@@ -521,7 +555,7 @@ extern const CGSize YYTextContainerMaxSize;
  @param view  The attachment views will add to this view.
  @param view  The attachment views will add to this view.
  @param layer The attachment layers will add to this layer.
  @param layer The attachment layers will add to this layer.
  */
  */
-- (void)addAttachmentToView:(UIView *)view layer:(CALayer *)layer;
+- (void)addAttachmentToView:(nullable UIView *)view layer:(nullable CALayer *)layer;
 
 
 /**
 /**
  Remove attachment views and layers from their super container.
  Remove attachment views and layers from their super container.
@@ -531,3 +565,5 @@ extern const CGSize YYTextContainerMaxSize;
 - (void)removeAttachmentFromViewAndLayer;
 - (void)removeAttachmentFromViewAndLayer;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 14 - 10
YYText/Component/YYTextLine.h

@@ -18,6 +18,10 @@
 #import "YYTextAttribute.h"
 #import "YYTextAttribute.h"
 #endif
 #endif
 
 
+@class YYTextRunGlyphRange;
+
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A text line object wrapped `CTLineRef`, see `YYTextLayout` for more.
  A text line object wrapped `CTLineRef`, see `YYTextLayout` for more.
  */
  */
@@ -25,9 +29,9 @@
 
 
 + (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical;
 + (instancetype)lineWithCTLine:(CTLineRef)CTLine position:(CGPoint)position vertical:(BOOL)isVertical;
 
 
-@property (nonatomic, assign) NSUInteger index;     ///< line index
-@property (nonatomic, assign) NSUInteger row;       ///< line row
-@property (nonatomic, strong) NSArray *verticalRotateRange; ///< Run rotate range Array<Array<YYTextRunGlyphRange>>
+@property (nonatomic) NSUInteger index;     ///< line index
+@property (nonatomic) NSUInteger row;       ///< line row
+@property (nullable, nonatomic, strong) NSArray<NSArray<YYTextRunGlyphRange *> *> *verticalRotateRange; ///< Run rotate range
 
 
 @property (nonatomic, readonly) CTLineRef CTLine;   ///< CoreText line
 @property (nonatomic, readonly) CTLineRef CTLine;   ///< CoreText line
 @property (nonatomic, readonly) NSRange range;      ///< string range
 @property (nonatomic, readonly) NSRange range;      ///< string range
@@ -42,16 +46,16 @@
 @property (nonatomic, readonly) CGFloat left;       ///< bounds.origin.x
 @property (nonatomic, readonly) CGFloat left;       ///< bounds.origin.x
 @property (nonatomic, readonly) CGFloat right;      ///< bounds.origin.x + bounds.size.width
 @property (nonatomic, readonly) CGFloat right;      ///< bounds.origin.x + bounds.size.width
 
 
-@property (nonatomic, assign)   CGPoint position;   ///< baseline position
+@property (nonatomic)   CGPoint position;   ///< baseline position
 @property (nonatomic, readonly) CGFloat ascent;     ///< line ascent
 @property (nonatomic, readonly) CGFloat ascent;     ///< line ascent
 @property (nonatomic, readonly) CGFloat descent;    ///< line descent
 @property (nonatomic, readonly) CGFloat descent;    ///< line descent
 @property (nonatomic, readonly) CGFloat leading;    ///< line leading
 @property (nonatomic, readonly) CGFloat leading;    ///< line leading
 @property (nonatomic, readonly) CGFloat lineWidth;  ///< line width
 @property (nonatomic, readonly) CGFloat lineWidth;  ///< line width
 @property (nonatomic, readonly) CGFloat trailingWhitespaceWidth;
 @property (nonatomic, readonly) CGFloat trailingWhitespaceWidth;
 
 
-@property (nonatomic, readonly) NSArray *attachments;      ///< YYTextAttachment
-@property (nonatomic, readonly) NSArray *attachmentRanges; ///< NSRange(NSValue)
-@property (nonatomic, readonly) NSArray *attachmentRects;  ///< CGRect(NSValue)
+@property (nonatomic, readonly) NSArray<YYTextAttachment *> *attachments; ///< YYTextAttachment
+@property (nonatomic, readonly) NSArray<NSValue *> *attachmentRanges;     ///< NSRange(NSValue)
+@property (nonatomic, readonly) NSArray<NSValue *> *attachmentRects;      ///< CGRect(NSValue)
 
 
 @end
 @end
 
 
@@ -72,9 +76,9 @@ typedef NS_ENUM(NSUInteger, YYTextRunGlyphDrawMode) {
  A range in CTRun, used for vertical form.
  A range in CTRun, used for vertical form.
  */
  */
 @interface YYTextRunGlyphRange : NSObject
 @interface YYTextRunGlyphRange : NSObject
-@property (nonatomic, assign) NSRange glyphRangeInRun;
-@property (nonatomic, assign) YYTextRunGlyphDrawMode drawMode;
+@property (nonatomic) NSRange glyphRangeInRun;
+@property (nonatomic) YYTextRunGlyphDrawMode drawMode;
 + (instancetype)rangeWithRange:(NSRange)range drawMode:(YYTextRunGlyphDrawMode)mode;
 + (instancetype)rangeWithRange:(NSRange)range drawMode:(YYTextRunGlyphDrawMode)mode;
 @end
 @end
 
 
-
+NS_ASSUME_NONNULL_END

+ 14 - 10
YYText/Component/YYTextMagnifier.h

@@ -17,6 +17,8 @@
 #import "YYTextAttribute.h"
 #import "YYTextAttribute.h"
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /// Magnifier type
 /// Magnifier type
 typedef NS_ENUM(NSInteger, YYTextMagnifierType) {
 typedef NS_ENUM(NSInteger, YYTextMagnifierType) {
     YYTextMagnifierTypeCaret,  ///< Circular magnifier
     YYTextMagnifierTypeCaret,  ///< Circular magnifier
@@ -34,16 +36,18 @@ typedef NS_ENUM(NSInteger, YYTextMagnifierType) {
 /// Create a mangifier with the specified type. @param type The magnifier type.
 /// Create a mangifier with the specified type. @param type The magnifier type.
 + (id)magnifierWithType:(YYTextMagnifierType)type;
 + (id)magnifierWithType:(YYTextMagnifierType)type;
 
 
-@property (nonatomic, readonly) YYTextMagnifierType type; ///< Type of magnifier
-@property (nonatomic, readonly) CGSize fitSize;           ///< The 'best' size for magnifier view.
-@property (nonatomic, readonly) CGSize snapshotSize;      ///< The 'best' snapshot image size for magnifier.
-@property (nonatomic, strong) UIImage *snapshot;          ///< The image in magnifier (readwrite).
+@property (nonatomic, readonly) YYTextMagnifierType type;  ///< Type of magnifier
+@property (nonatomic, readonly) CGSize fitSize;            ///< The 'best' size for magnifier view.
+@property (nonatomic, readonly) CGSize snapshotSize;       ///< The 'best' snapshot image size for magnifier.
+@property (nullable, nonatomic, strong) UIImage *snapshot; ///< The image in magnifier (readwrite).
 
 
-@property (nonatomic, weak) UIView *hostView;             ///< The coordinate based view.
-@property (nonatomic, assign) CGPoint hostCaptureCenter;  ///< The snapshot capture center in `hostView`.
-@property (nonatomic, assign) CGPoint hostPopoverCenter;  ///< The popover center in `hostView`.
-@property (nonatomic, assign) BOOL hostVerticalForm;      ///< The host view is vertical form.
-@property (nonatomic, assign) BOOL captureDisabled;       ///< A hint for `YYTextEffectWindow` to disable capture.
-@property (nonatomic, assign) BOOL captureFadeAnimation;  ///< Show fade animation when the snapshot image changed.
+@property (nullable, nonatomic, weak) UIView *hostView;   ///< The coordinate based view.
+@property (nonatomic) CGPoint hostCaptureCenter;          ///< The snapshot capture center in `hostView`.
+@property (nonatomic) CGPoint hostPopoverCenter;          ///< The popover center in `hostView`.
+@property (nonatomic) BOOL hostVerticalForm;              ///< The host view is vertical form.
+@property (nonatomic) BOOL captureDisabled;               ///< A hint for `YYTextEffectWindow` to disable capture.
+@property (nonatomic) BOOL captureFadeAnimation;          ///< Show fade animation when the snapshot image changed.
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 13 - 9
YYText/Component/YYTextSelectionView.h

@@ -19,6 +19,8 @@
 #import "YYTextInput.h"
 #import "YYTextInput.h"
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A single dot view. The frame should be foursquare.
  A single dot view. The frame should be foursquare.
  Change the background color for display.
  Change the background color for display.
@@ -39,8 +41,8 @@
 @interface YYSelectionGrabber : UIView
 @interface YYSelectionGrabber : UIView
 
 
 @property (nonatomic, readonly) YYSelectionGrabberDot *dot; ///< the dot view
 @property (nonatomic, readonly) YYSelectionGrabberDot *dot; ///< the dot view
-@property (nonatomic, assign) YYTextDirection dotDirection; ///< don't support composite direction
-@property (nonatomic, strong) UIColor *color; ///< tint color, default is nil
+@property (nonatomic) YYTextDirection dotDirection;         ///< don't support composite direction
+@property (nullable, nonatomic, strong) UIColor *color;     ///< tint color, default is nil
 
 
 @end
 @end
 
 
@@ -52,14 +54,14 @@
  */
  */
 @interface YYTextSelectionView : UIView
 @interface YYTextSelectionView : UIView
 
 
-@property (nonatomic, weak) UIView *hostView; ///< the holder view
-@property (nonatomic, strong) UIColor *color; ///< the tint color
-@property (nonatomic, assign, getter = isCaretBlinks) BOOL caretBlinks; ///< whether the caret is blinks
-@property (nonatomic, assign, getter = isCaretVisible) BOOL caretVisible; ///< whether the caret is visible
-@property (nonatomic, assign, getter = isVerticalForm) BOOL verticalForm; ///< weather the text view is vertical form
+@property (nullable, nonatomic, weak) UIView *hostView; ///< the holder view
+@property (nullable, nonatomic, strong) UIColor *color; ///< the tint color
+@property (nonatomic, getter = isCaretBlinks) BOOL caretBlinks; ///< whether the caret is blinks
+@property (nonatomic, getter = isCaretVisible) BOOL caretVisible; ///< whether the caret is visible
+@property (nonatomic, getter = isVerticalForm) BOOL verticalForm; ///< weather the text view is vertical form
 
 
-@property (nonatomic, assign) CGRect caretRect; ///< caret rect (width==0 or height==0)
-@property (nonatomic, copy) NSArray *selectionRects; ///<  array of YYTextSelectionRect, default is nil
+@property (nonatomic) CGRect caretRect; ///< caret rect (width==0 or height==0)
+@property (nullable, nonatomic, copy) NSArray<YYTextSelectionRect *> *selectionRects; ///< default is nil
 
 
 @property (nonatomic, readonly) UIView *caretView;
 @property (nonatomic, readonly) UIView *caretView;
 @property (nonatomic, readonly) YYSelectionGrabber *startGrabber;
 @property (nonatomic, readonly) YYSelectionGrabber *startGrabber;
@@ -72,3 +74,5 @@
 - (BOOL)isSelectionRectsContainsPoint:(CGPoint)point;
 - (BOOL)isSelectionRectsContainsPoint:(CGPoint)point;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
YYText/String/YYTextArchiver.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A subclass of `NSKeyedArchiver` which implement `NSKeyedArchiverDelegate` protocol.
  A subclass of `NSKeyedArchiver` which implement `NSKeyedArchiverDelegate` protocol.
  
  
@@ -26,4 +28,6 @@
  `YYTextArchiver` or `NSKeyedArchiver`.
  `YYTextArchiver` or `NSKeyedArchiver`.
  */
  */
 @interface YYTextUnarchiver : NSKeyedUnarchiver <NSKeyedUnarchiverDelegate>
 @interface YYTextUnarchiver : NSKeyedUnarchiver <NSKeyedUnarchiverDelegate>
-@end
+@end
+
+NS_ASSUME_NONNULL_END

+ 49 - 47
YYText/String/YYTextAttribute.h

@@ -11,6 +11,7 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - Enum Define
 #pragma mark - Enum Define
 
 
@@ -171,9 +172,9 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  It may used for copy/paste plain text from attributed string.
  It may used for copy/paste plain text from attributed string.
  Example: If :) is replace by a custom emoji (such as😊), the backed string can be set to @":)".
  Example: If :) is replace by a custom emoji (such as😊), the backed string can be set to @":)".
  */
  */
-@interface YYTextBackedString : NSObject <NSCoding,NSCopying>
-+ (instancetype)stringWithString:(NSString *)string;
-@property (nonatomic, copy) NSString *string; ///< backed string
+@interface YYTextBackedString : NSObject <NSCoding, NSCopying>
++ (instancetype)stringWithString:(nullable NSString *)string;
+@property (nullable, nonatomic, copy) NSString *string; ///< backed string
 @end
 @end
 
 
 
 
@@ -188,7 +189,7 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  */
  */
 @interface YYTextBinding : NSObject <NSCoding, NSCopying>
 @interface YYTextBinding : NSObject <NSCoding, NSCopying>
 + (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm;
 + (instancetype)bindingWithDeleteConfirm:(BOOL)deleteConfirm;
-@property (nonatomic, assign) BOOL deleteConfirm; ///< confirm the range when delete in YYTextView
+@property (nonatomic) BOOL deleteConfirm; ///< confirm the range when delete in YYTextView
 @end
 @end
 
 
 
 
@@ -200,13 +201,13 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  It's similar to `NSShadow`, but offers more options.
  It's similar to `NSShadow`, but offers more options.
  */
  */
 @interface YYTextShadow : NSObject <NSCoding, NSCopying>
 @interface YYTextShadow : NSObject <NSCoding, NSCopying>
-+ (instancetype)shadowWithColor:(UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius;
++ (instancetype)shadowWithColor:(nullable UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius;
 
 
-@property (nonatomic, strong) UIColor *color;           ///< shadow color
-@property (nonatomic, assign) CGSize offset;            ///< shadow offset
-@property (nonatomic, assign) CGFloat radius;           ///< shadow blur radius
-@property (nonatomic, assign) CGBlendMode blendMode;    ///< shadow blend mode
-@property (nonatomic, strong) YYTextShadow *subShadow;  ///< a sub shadow which will be added above the parent shadow
+@property (nullable, nonatomic, strong) UIColor *color; ///< shadow color
+@property (nonatomic) CGSize offset;                    ///< shadow offset
+@property (nonatomic) CGFloat radius;                   ///< shadow blur radius
+@property (nonatomic) CGBlendMode blendMode;            ///< shadow blend mode
+@property (nullable, nonatomic, strong) YYTextShadow *subShadow;  ///< a sub shadow which will be added above the parent shadow
 
 
 + (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow; ///< convert NSShadow to YYTextShadow
 + (instancetype)shadowWithNSShadow:(NSShadow *)nsShadow; ///< convert NSShadow to YYTextShadow
 - (NSShadow *)nsShadow; ///< convert YYTextShadow to NSShadow
 - (NSShadow *)nsShadow; ///< convert YYTextShadow to NSShadow
@@ -223,11 +224,11 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  */
  */
 @interface YYTextDecoration : NSObject <NSCoding, NSCopying>
 @interface YYTextDecoration : NSObject <NSCoding, NSCopying>
 + (instancetype)decorationWithStyle:(YYTextLineStyle)style;
 + (instancetype)decorationWithStyle:(YYTextLineStyle)style;
-+ (instancetype)decorationWithStyle:(YYTextLineStyle)style width:(NSNumber *)width color:(UIColor *)color;
-@property (nonatomic, assign) YYTextLineStyle style; ///< line style
-@property (nonatomic, strong) NSNumber *width;       ///< line width (nil means automatic width)
-@property (nonatomic, strong) UIColor *color;        ///< line color (nil means automatic color)
-@property (nonatomic, strong) YYTextShadow *shadow;  ///< line shadow
++ (instancetype)decorationWithStyle:(YYTextLineStyle)style width:(nullable NSNumber *)width color:(nullable UIColor *)color;
+@property (nonatomic) YYTextLineStyle style;                   ///< line style
+@property (nullable, nonatomic, strong) NSNumber *width;       ///< line width (nil means automatic width)
+@property (nullable, nonatomic, strong) UIColor *color;        ///< line color (nil means automatic color)
+@property (nullable, nonatomic, strong) YYTextShadow *shadow;  ///< line shadow
 @end
 @end
 
 
 
 
@@ -245,16 +246,16 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
     ╰──────╯
     ╰──────╯
  */
  */
 @interface YYTextBorder : NSObject <NSCoding, NSCopying>
 @interface YYTextBorder : NSObject <NSCoding, NSCopying>
-+ (instancetype)borderWithLineStyle:(YYTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(UIColor *)color;
-+ (instancetype)borderWithFillColor:(UIColor *)color cornerRadius:(CGFloat)cornerRadius;
-@property (nonatomic, assign) YYTextLineStyle lineStyle; ///< border line style
-@property (nonatomic, assign) CGFloat strokeWidth;       ///< border line width
-@property (nonatomic, strong) UIColor *strokeColor;      ///< border line color
-@property (nonatomic, assign) CGLineJoin lineJoin;       ///< border line join
-@property (nonatomic, assign) UIEdgeInsets insets;       ///< border insets for text bounds
-@property (nonatomic, assign) CGFloat cornerRadius;      ///< border corder radius
-@property (nonatomic, strong) YYTextShadow *shadow;      ///< border shadow
-@property (nonatomic, strong) UIColor *fillColor;        ///< inner fill color
++ (instancetype)borderWithLineStyle:(YYTextLineStyle)lineStyle lineWidth:(CGFloat)width strokeColor:(nullable UIColor *)color;
++ (instancetype)borderWithFillColor:(nullable UIColor *)color cornerRadius:(CGFloat)cornerRadius;
+@property (nonatomic) YYTextLineStyle lineStyle;              ///< border line style
+@property (nonatomic) CGFloat strokeWidth;                    ///< border line width
+@property (nullable, nonatomic, strong) UIColor *strokeColor; ///< border line color
+@property (nonatomic) CGLineJoin lineJoin;                    ///< border line join
+@property (nonatomic) UIEdgeInsets insets;                    ///< border insets for text bounds
+@property (nonatomic) CGFloat cornerRadius;                   ///< border corder radius
+@property (nullable, nonatomic, strong) YYTextShadow *shadow; ///< border shadow
+@property (nullable, nonatomic, strong) UIColor *fillColor;   ///< inner fill color
 @end
 @end
 
 
 
 
@@ -269,11 +270,11 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  then it will be added to the text container's view or layer.
  then it will be added to the text container's view or layer.
  */
  */
 @interface YYTextAttachment : NSObject<NSCoding, NSCopying>
 @interface YYTextAttachment : NSObject<NSCoding, NSCopying>
-+ (instancetype)attachmentWithContent:(id)content;
-@property (nonatomic, strong) id content;                    ///< Supported type: UIImage, UIView, CALayer
-@property (nonatomic, assign) UIViewContentMode contentMode; ///< Content display mode.
-@property (nonatomic, assign) UIEdgeInsets contentInsets;    ///< The insets when drawing content.
-@property (nonatomic, strong) NSDictionary *userInfo;        ///< The user information dictionary.
++ (instancetype)attachmentWithContent:(nullable id)content;
+@property (nullable, nonatomic, strong) id content;             ///< Supported type: UIImage, UIView, CALayer
+@property (nonatomic) UIViewContentMode contentMode;            ///< Content display mode.
+@property (nonatomic) UIEdgeInsets contentInsets;               ///< The insets when drawing content.
+@property (nullable, nonatomic, strong) NSDictionary *userInfo; ///< The user information dictionary.
 @end
 @end
 
 
 
 
@@ -294,7 +295,7 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  Key:   Same as CoreText/YYText Attribute Name.
  Key:   Same as CoreText/YYText Attribute Name.
  Value: Modify attribute value when highlight (NSNull for remove attribute).
  Value: Modify attribute value when highlight (NSNull for remove attribute).
  */
  */
-@property (nonatomic, copy) NSDictionary *attributes;
+@property (nullable, nonatomic, copy) NSDictionary<NSString *, id> *attributes;
 
 
 /**
 /**
  Creates a highlight object with specified attributes.
  Creates a highlight object with specified attributes.
@@ -302,44 +303,45 @@ typedef void(^YYTextAction)(UIView *containerView, NSAttributedString *text, NSR
  @param attributes The attributes which will replace original attributes when highlight,
  @param attributes The attributes which will replace original attributes when highlight,
         If the value is NSNull, it will removed when highlight.
         If the value is NSNull, it will removed when highlight.
  */
  */
-+ (instancetype)highlightWithAttributes:(NSDictionary *)attributes;
++ (instancetype)highlightWithAttributes:(nullable NSDictionary<NSString *, id> *)attributes;
 
 
 /**
 /**
  Convenience methods to create a default highlight with the specifeid background color.
  Convenience methods to create a default highlight with the specifeid background color.
  
  
  @param color The background border color.
  @param color The background border color.
  */
  */
-+ (instancetype)highlightWithBackgroundColor:(UIColor *)color;
++ (instancetype)highlightWithBackgroundColor:(nullable UIColor *)color;
 
 
 // Convenience methods below to set the `attributes`.
 // Convenience methods below to set the `attributes`.
-- (void)setFont:(UIFont *)font;
-- (void)setColor:(UIColor *)color;
-- (void)setStrokeWidth:(NSNumber *)width;
-- (void)setStrokeColor:(UIColor *)color;
-- (void)setShadow:(YYTextShadow *)shadow;
-- (void)setInnerShadow:(YYTextShadow *)shadow;
-- (void)setUnderline:(YYTextDecoration *)underline;
-- (void)setStrikethrough:(YYTextDecoration *)strikethrough;
-- (void)setBackgroundBorder:(YYTextBorder *)border;
-- (void)setBorder:(YYTextBorder *)border;
-- (void)setAttachment:(YYTextAttachment *)attachment;
+- (void)setFont:(nullable UIFont *)font;
+- (void)setColor:(nullable UIColor *)color;
+- (void)setStrokeWidth:(nullable NSNumber *)width;
+- (void)setStrokeColor:(nullable UIColor *)color;
+- (void)setShadow:(nullable YYTextShadow *)shadow;
+- (void)setInnerShadow:(nullable YYTextShadow *)shadow;
+- (void)setUnderline:(nullable YYTextDecoration *)underline;
+- (void)setStrikethrough:(nullable YYTextDecoration *)strikethrough;
+- (void)setBackgroundBorder:(nullable YYTextBorder *)border;
+- (void)setBorder:(nullable YYTextBorder *)border;
+- (void)setAttachment:(nullable YYTextAttachment *)attachment;
 
 
 /**
 /**
  The user information dictionary, default is nil.
  The user information dictionary, default is nil.
  */
  */
-@property (nonatomic, copy) NSDictionary *userInfo;
+@property (nullable, nonatomic, copy) NSDictionary *userInfo;
 
 
 /**
 /**
  Tap action when user tap the highlight, default is nil.
  Tap action when user tap the highlight, default is nil.
  If the value is nil, YYTextView or YYLabel will ask it's delegate to deal with tap action.
  If the value is nil, YYTextView or YYLabel will ask it's delegate to deal with tap action.
  */
  */
-@property (nonatomic, copy) YYTextAction tapAction;
+@property (nullable, nonatomic, copy) YYTextAction tapAction;
 
 
 /**
 /**
  Long press action when user long press the highlight, default is nil.
  Long press action when user long press the highlight, default is nil.
  If the value is nil, YYTextView or YYLabel will ask it's delegate to deal with long press action.
  If the value is nil, YYTextView or YYLabel will ask it's delegate to deal with long press action.
  */
  */
-@property (nonatomic, copy) YYTextAction longPressAction;
+@property (nullable, nonatomic, copy) YYTextAction longPressAction;
 
 
 @end
 @end
 
 
+NS_ASSUME_NONNULL_END

+ 14 - 10
YYText/String/YYTextParser.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  The YYTextParser protocol declares the required method for YYTextView and YYLabel
  The YYTextParser protocol declares the required method for YYTextView and YYLabel
  to modify the text during editing.
  to modify the text during editing.
@@ -32,7 +34,7 @@
  
  
  @return If the 'text' is modified in this method, returns `YES`, otherwise returns `NO`.
  @return If the 'text' is modified in this method, returns `YES`, otherwise returns `NO`.
  */
  */
-- (BOOL)parseText:(NSMutableAttributedString *)text selectedRange:(NSRangePointer)selectedRange;
+- (BOOL)parseText:(nullable NSMutableAttributedString *)text selectedRange:(nullable NSRangePointer)selectedRange;
 @end
 @end
 
 
 
 
@@ -52,15 +54,15 @@
  Or you can use lex/yacc to generate your custom parser.
  Or you can use lex/yacc to generate your custom parser.
  */
  */
 @interface YYTextSimpleMarkdownParser : NSObject <YYTextParser>
 @interface YYTextSimpleMarkdownParser : NSObject <YYTextParser>
-@property (nonatomic, assign) CGFloat fontSize;         ///< default is 14
-@property (nonatomic, assign) CGFloat headerFontSize;   ///< default is 20
+@property (nonatomic) CGFloat fontSize;         ///< default is 14
+@property (nonatomic) CGFloat headerFontSize;   ///< default is 20
 
 
-@property (nonatomic, strong) UIColor *textColor;
-@property (nonatomic, strong) UIColor *controlTextColor;
-@property (nonatomic, strong) UIColor *headerTextColor;
-@property (nonatomic, strong) UIColor *inlineTextColor;
-@property (nonatomic, strong) UIColor *codeTextColor;
-@property (nonatomic, strong) UIColor *linkTextColor;
+@property (nullable, nonatomic, strong) UIColor *textColor;
+@property (nullable, nonatomic, strong) UIColor *controlTextColor;
+@property (nullable, nonatomic, strong) UIColor *headerTextColor;
+@property (nullable, nonatomic, strong) UIColor *inlineTextColor;
+@property (nullable, nonatomic, strong) UIColor *codeTextColor;
+@property (nullable, nonatomic, strong) UIColor *linkTextColor;
 
 
 - (void)setColorWithBrightTheme; ///< reset the color properties to pre-defined value.
 - (void)setColorWithBrightTheme; ///< reset the color properties to pre-defined value.
 - (void)setColorWithDarkTheme;   ///< reset the color properties to pre-defined value.
 - (void)setColorWithDarkTheme;   ///< reset the color properties to pre-defined value.
@@ -83,5 +85,7 @@
  The key is a specified plain string, such as @":smile:".
  The key is a specified plain string, such as @":smile:".
  The value is a UIImage which will replace the specified plain string in text.
  The value is a UIImage which will replace the specified plain string in text.
  */
  */
-@property (copy) NSDictionary *emoticonMapper;
+@property (nullable, copy) NSDictionary<NSString *, __kindof UIImage *> *emoticonMapper;
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 12 - 8
YYText/String/YYTextRubyAnnotation.h

@@ -12,6 +12,8 @@
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 #import <CoreText/CoreText.h>
 #import <CoreText/CoreText.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Wrapper for CTRubyAnnotationRef.
  Wrapper for CTRubyAnnotationRef.
  
  
@@ -29,29 +31,29 @@
 @interface YYTextRubyAnnotation : NSObject <NSCopying, NSCoding>
 @interface YYTextRubyAnnotation : NSObject <NSCopying, NSCoding>
 
 
 /// Specifies how the ruby text and the base text should be aligned relative to each other.
 /// Specifies how the ruby text and the base text should be aligned relative to each other.
-@property (nonatomic, assign) CTRubyAlignment alignment;
+@property (nonatomic) CTRubyAlignment alignment;
 
 
 /// Specifies how the ruby text can overhang adjacent characters.
 /// Specifies how the ruby text can overhang adjacent characters.
-@property (nonatomic, assign) CTRubyOverhang overhang;
+@property (nonatomic) CTRubyOverhang overhang;
 
 
 /// Specifies the size of the annotation text as a percent of the size of the base text.
 /// Specifies the size of the annotation text as a percent of the size of the base text.
-@property (nonatomic, assign) CGFloat sizeFactor;
+@property (nonatomic) CGFloat sizeFactor;
 
 
 
 
 /// The ruby text is positioned before the base text;
 /// The ruby text is positioned before the base text;
 /// i.e. above horizontal text and to the right of vertical text.
 /// i.e. above horizontal text and to the right of vertical text.
-@property (nonatomic, copy) NSString *textBefore;
+@property (nullable, nonatomic, copy) NSString *textBefore;
 
 
 /// The ruby text is positioned after the base text;
 /// The ruby text is positioned after the base text;
 /// i.e. below horizontal text and to the left of vertical text.
 /// i.e. below horizontal text and to the left of vertical text.
-@property (nonatomic, copy) NSString *textAfter;
+@property (nullable, nonatomic, copy) NSString *textAfter;
 
 
 /// The ruby text is positioned to the right of the base text whether it is horizontal or vertical.
 /// The ruby text is positioned to the right of the base text whether it is horizontal or vertical.
 /// This is the way that Bopomofo annotations are attached to Chinese text in Taiwan.
 /// This is the way that Bopomofo annotations are attached to Chinese text in Taiwan.
-@property (nonatomic, copy) NSString *textInterCharacter;
+@property (nullable, nonatomic, copy) NSString *textInterCharacter;
 
 
 /// The ruby text follows the base text with no special styling.
 /// The ruby text follows the base text with no special styling.
-@property (nonatomic, copy) NSString *textInline;
+@property (nullable, nonatomic, copy) NSString *textInline;
 
 
 
 
 /**
 /**
@@ -69,6 +71,8 @@
  @return A new CTRuby object, or NULL when an error occurs.
  @return A new CTRuby object, or NULL when an error occurs.
  The returned value should be release after used.
  The returned value should be release after used.
  */
  */
-- (CTRubyAnnotationRef)CTRubyAnnotation CF_RETURNS_RETAINED NS_AVAILABLE_IOS(8_0);
+- (nullable CTRubyAnnotationRef)CTRubyAnnotation CF_RETURNS_RETAINED NS_AVAILABLE_IOS(8_0);
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 9 - 5
YYText/String/YYTextRunDelegate.h

@@ -12,6 +12,8 @@
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 #import <CoreText/CoreText.h>
 #import <CoreText/CoreText.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Wrapper for CTRunDelegateRef.
  Wrapper for CTRunDelegateRef.
  
  
@@ -39,26 +41,28 @@
  
  
  @return The CTRunDelegate object.
  @return The CTRunDelegate object.
  */
  */
-- (CTRunDelegateRef)CTRunDelegate CF_RETURNS_RETAINED;
+- (nullable CTRunDelegateRef)CTRunDelegate CF_RETURNS_RETAINED;
 
 
 /**
 /**
  Additional information about the the run delegate.
  Additional information about the the run delegate.
  */
  */
-@property (nonatomic, strong) NSDictionary *userInfo;
+@property (nullable, nonatomic, strong) NSDictionary *userInfo;
 
 
 /**
 /**
  The typographic ascent of glyphs in the run.
  The typographic ascent of glyphs in the run.
  */
  */
-@property (nonatomic, assign) CGFloat ascent;
+@property (nonatomic) CGFloat ascent;
 
 
 /**
 /**
  The typographic descent of glyphs in the run.
  The typographic descent of glyphs in the run.
  */
  */
-@property (nonatomic, assign) CGFloat descent;
+@property (nonatomic) CGFloat descent;
 
 
 /**
 /**
  The typographic width of glyphs in the run.
  The typographic width of glyphs in the run.
  */
  */
-@property (nonatomic, assign) CGFloat width;
+@property (nonatomic) CGFloat width;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 164 - 166
YYText/Utility/NSAttributedString+YYText.h


+ 6 - 2
YYText/Utility/NSParagraphStyle+YYText.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Provides extensions for `NSParagraphStyle` to work with CoreText.
  Provides extensions for `NSParagraphStyle` to work with CoreText.
  */
  */
@@ -23,11 +25,13 @@
  
  
  @return a new NSParagraphStyle
  @return a new NSParagraphStyle
  */
  */
-+ (NSParagraphStyle *)yy_styleWithCTStyle:(CTParagraphStyleRef)CTStyle;
++ (nullable NSParagraphStyle *)yy_styleWithCTStyle:(CTParagraphStyleRef)CTStyle;
 
 
 /**
 /**
  Creates and returns a CoreText Paragraph Style. (need call CFRelease() after used)
  Creates and returns a CoreText Paragraph Style. (need call CFRelease() after used)
  */
  */
-- (CTParagraphStyleRef)yy_CTStyle CF_RETURNS_RETAINED;
+- (nullable CTParagraphStyleRef)yy_CTStyle CF_RETURNS_RETAINED;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 10 - 6
YYText/Utility/UIPasteboard+YYText.h

@@ -11,21 +11,23 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Extend UIPasteboard to support image and attributed string.
  Extend UIPasteboard to support image and attributed string.
  */
  */
 @interface UIPasteboard (YYText)
 @interface UIPasteboard (YYText)
 
 
-@property (nonatomic, copy) NSData *yy_PNGData;    ///< PNG file data
-@property (nonatomic, copy) NSData *yy_JPEGData;   ///< JPEG file data
-@property (nonatomic, copy) NSData *yy_GIFData;    ///< GIF file data
-@property (nonatomic, copy) NSData *yy_WEBPData;   ///< WebP file data
-@property (nonatomic, copy) NSData *yy_ImageData;  ///< image file data
+@property (nullable, nonatomic, copy) NSData *yy_PNGData;    ///< PNG file data
+@property (nullable, nonatomic, copy) NSData *yy_JPEGData;   ///< JPEG file data
+@property (nullable, nonatomic, copy) NSData *yy_GIFData;    ///< GIF file data
+@property (nullable, nonatomic, copy) NSData *yy_WEBPData;   ///< WebP file data
+@property (nullable, nonatomic, copy) NSData *yy_ImageData;  ///< image file data
 
 
 /// Attributed string,
 /// Attributed string,
 /// Set this attributed will also set the string property which is copy from the attributed string.
 /// Set this attributed will also set the string property which is copy from the attributed string.
 /// If the attributed string contains one or more image, it will also set the `images` property.
 /// If the attributed string contains one or more image, it will also set the `images` property.
-@property (nonatomic, copy) NSAttributedString *yy_AttributedString;
+@property (nullable, nonatomic, copy) NSAttributedString *yy_AttributedString;
 
 
 @end
 @end
 
 
@@ -35,3 +37,5 @@ UIKIT_EXTERN NSString *const YYTextPasteboardTypeAttributedString;
 
 
 /// The UTI Type identifying WebP data in pasteboard.
 /// The UTI Type identifying WebP data in pasteboard.
 UIKIT_EXTERN NSString *const YYTextUTTypeWEBP;
 UIKIT_EXTERN NSString *const YYTextUTTypeWEBP;
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
YYText/Utility/UIView+YYText.h

@@ -11,6 +11,8 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  Provides extensions for `UIView`.
  Provides extensions for `UIView`.
  */
  */
@@ -19,7 +21,7 @@
 /**
 /**
  Returns the view's view controller (may be nil).
  Returns the view's view controller (may be nil).
  */
  */
-@property (nonatomic, readonly) UIViewController *yy_viewController;
+@property (nullable, nonatomic, readonly) UIViewController *yy_viewController;
 
 
 /**
 /**
  Returns the visible alpha on screen, taking into account superview and window.
  Returns the visible alpha on screen, taking into account superview and window.
@@ -66,3 +68,5 @@
 - (CGRect)yy_convertRect:(CGRect)rect fromViewOrWindow:(UIView *)view;
 - (CGRect)yy_convertRect:(CGRect)rect fromViewOrWindow:(UIView *)view;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 6 - 3
YYText/Utility/YYTextAsyncLayer.h

@@ -14,6 +14,7 @@
 
 
 @class YYTextAsyncLayerDisplayTask;
 @class YYTextAsyncLayerDisplayTask;
 
 
+NS_ASSUME_NONNULL_BEGIN
 
 
 /**
 /**
  The YYTextAsyncLayer class is a subclass of CALayer used for render contents asynchronously.
  The YYTextAsyncLayer class is a subclass of CALayer used for render contents asynchronously.
@@ -49,7 +50,7 @@
  
  
  @param layer  The layer.
  @param layer  The layer.
  */
  */
-@property (nonatomic, copy) void (^willDisplay)(CALayer *layer);
+@property (nullable, nonatomic, copy) void (^willDisplay)(CALayer *layer);
 
 
 /**
 /**
  This block is called to draw the layer's contents.
  This block is called to draw the layer's contents.
@@ -62,7 +63,7 @@
  @param isCancelled  If this block returns `YES`, the method should cancel the
  @param isCancelled  If this block returns `YES`, the method should cancel the
  drawing process and return as quickly as possible.
  drawing process and return as quickly as possible.
  */
  */
-@property (nonatomic, copy) void (^display)(CGContextRef context, CGSize size, BOOL(^isCancelled)(void));
+@property (nullable, nonatomic, copy) void (^display)(CGContextRef context, CGSize size, BOOL(^isCancelled)(void));
 
 
 /**
 /**
  This block will be called after the asynchronous drawing finished.
  This block will be called after the asynchronous drawing finished.
@@ -71,6 +72,8 @@
  @param layer  The layer.
  @param layer  The layer.
  @param finished  If the draw process is cancelled, it's `NO`, otherwise it's `YES`;
  @param finished  If the draw process is cancelled, it's `NO`, otherwise it's `YES`;
  */
  */
-@property (nonatomic, copy) void (^didDisplay)(CALayer *layer, BOOL finished);
+@property (nullable, nonatomic, copy) void (^didDisplay)(CALayer *layer, BOOL finished);
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 4 - 0
YYText/Utility/YYTextTransaction.h

@@ -11,6 +11,8 @@
 
 
 #import <Foundation/Foundation.h>
 #import <Foundation/Foundation.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  YYTextTransaction let you perform a selector once before current runloop sleep.
  YYTextTransaction let you perform a selector once before current runloop sleep.
  */
  */
@@ -36,3 +38,5 @@
 - (void)commit;
 - (void)commit;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 9 - 6
YYText/Utility/YYTextUtilities.h

@@ -22,6 +22,7 @@
 #define YYTEXT_SWAP(_a_, _b_)  do { __typeof__(_a_) _tmp_ = (_a_); (_a_) = (_b_); (_b_) = _tmp_; } while (0)
 #define YYTEXT_SWAP(_a_, _b_)  do { __typeof__(_a_) _tmp_ = (_a_); (_a_) = (_b_); (_b_) = _tmp_; } while (0)
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
 
 
 /**
 /**
  Whether the character is 'line break char':
  Whether the character is 'line break char':
@@ -56,7 +57,7 @@ static inline BOOL YYTextIsLinebreakChar(unichar c) {
  @param str A string
  @param str A string
  @return YES or NO.
  @return YES or NO.
  */
  */
-static inline BOOL YYTextIsLinebreakString(NSString *str) {
+static inline BOOL YYTextIsLinebreakString( NSString * _Nullable str) {
     if (str.length > 2 || str.length == 0) return NO;
     if (str.length > 2 || str.length == 0) return NO;
     if (str.length == 1) {
     if (str.length == 1) {
         unichar c = [str characterAtIndex:0];
         unichar c = [str characterAtIndex:0];
@@ -72,7 +73,7 @@ static inline BOOL YYTextIsLinebreakString(NSString *str) {
  @param str  A string.
  @param str  A string.
  @return The length of the tail line break: 0, 1 or 2.
  @return The length of the tail line break: 0, 1 or 2.
  */
  */
-static inline NSUInteger YYTextLinebreakTailLength(NSString *str) {
+static inline NSUInteger YYTextLinebreakTailLength(NSString * _Nullable str) {
     if (str.length >= 2) {
     if (str.length >= 2) {
         unichar c2 = [str characterAtIndex:str.length - 1];
         unichar c2 = [str characterAtIndex:str.length - 1];
         if (YYTextIsLinebreakChar(c2)) {
         if (YYTextIsLinebreakChar(c2)) {
@@ -519,17 +520,17 @@ static inline UIEdgeInsets YYTextUIEdgeInsetPixelCeil(UIEdgeInsets insets) {
 
 
 
 
 
 
-static inline UIFont * YYTextFontWithBold(UIFont *font) {
+static inline  UIFont * _Nullable YYTextFontWithBold(UIFont *font) {
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold] size:font.pointSize];
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold] size:font.pointSize];
 }
 }
 
 
-static inline UIFont * YYTextFontWithItalic(UIFont *font) {
+static inline UIFont * _Nullable YYTextFontWithItalic(UIFont *font) {
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic] size:font.pointSize];
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic] size:font.pointSize];
 }
 }
 
 
-static inline UIFont * YYTextFontWithBoldItalic(UIFont *font) {
+static inline UIFont * _Nullable YYTextFontWithBoldItalic(UIFont *font) {
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     if (![font respondsToSelector:@selector(fontDescriptor)]) return font;
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold | UIFontDescriptorTraitItalic] size:font.pointSize];
     return [UIFont fontWithDescriptor:[font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold | UIFontDescriptorTraitItalic] size:font.pointSize];
 }
 }
@@ -557,4 +558,6 @@ static inline CFRange YYTextCFRangeFromNSRange(NSRange range) {
 BOOL YYTextIsAppExtension();
 BOOL YYTextIsAppExtension();
 
 
 /// Returns nil in App Extension.
 /// Returns nil in App Extension.
-UIApplication *YYTextSharedApplication();
+UIApplication * _Nullable YYTextSharedApplication();
+
+NS_ASSUME_NONNULL_END

+ 5 - 1
YYText/Utility/YYTextWeakProxy.h

@@ -11,6 +11,8 @@
 
 
 #import <Foundation/Foundation.h>
 #import <Foundation/Foundation.h>
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  A proxy used to hold a weak object.
  A proxy used to hold a weak object.
  It can be used to avoid retain cycles, such as the target in NSTimer or CADisplayLink.
  It can be used to avoid retain cycles, such as the target in NSTimer or CADisplayLink.
@@ -34,7 +36,7 @@
 /**
 /**
  The proxy target.
  The proxy target.
  */
  */
-@property (nonatomic, weak, readonly) id target;
+@property (nullable, nonatomic, weak, readonly) id target;
 
 
 /**
 /**
  Creates a new weak proxy for target.
  Creates a new weak proxy for target.
@@ -55,3 +57,5 @@
 + (instancetype)proxyWithTarget:(id)target;
 + (instancetype)proxyWithTarget:(id)target;
 
 
 @end
 @end
+
+NS_ASSUME_NONNULL_END

+ 6 - 2
YYText/YYLabel.h

@@ -21,6 +21,8 @@
 #import "YYTextAttribute.h"
 #import "YYTextAttribute.h"
 #endif
 #endif
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 #if !TARGET_INTERFACE_BUILDER
 #if !TARGET_INTERFACE_BUILDER
 
 
 /**
 /**
@@ -158,7 +160,7 @@
  An array of UIBezierPath objects representing the exclusion paths inside the
  An array of UIBezierPath objects representing the exclusion paths inside the
  receiver's bounding rectangle. Default value is nil.
  receiver's bounding rectangle. Default value is nil.
  */
  */
-@property (nullable, nonatomic, copy) NSArray *exclusionPaths;
+@property (nullable, nonatomic, copy) NSArray<UIBezierPath *> *exclusionPaths;
 
 
 /**
 /**
  The inset of the text container's layout area within the text view's content area.
  The inset of the text container's layout area within the text view's content area.
@@ -359,7 +361,7 @@ IB_DESIGNABLE
 @property (nullable, nonatomic, strong) id<YYTextParser> textParser;
 @property (nullable, nonatomic, strong) id<YYTextParser> textParser;
 @property (nullable, nonatomic, strong) YYTextLayout *textLayout;
 @property (nullable, nonatomic, strong) YYTextLayout *textLayout;
 @property (nullable, nonatomic, copy) UIBezierPath *textContainerPath;
 @property (nullable, nonatomic, copy) UIBezierPath *textContainerPath;
-@property (nullable, nonatomic, copy) NSArray *exclusionPaths;
+@property (nullable, nonatomic, copy) NSArray<UIBezierPath*> *exclusionPaths;
 @property (nonatomic) UIEdgeInsets textContainerInset;
 @property (nonatomic) UIEdgeInsets textContainerInset;
 @property (nullable, nonatomic, copy) id<YYTextLinePositionModifier> linePositionModifier;
 @property (nullable, nonatomic, copy) id<YYTextLinePositionModifier> linePositionModifier;
 @property (nonnull, nonatomic, copy) YYTextDebugOption *debugOption;
 @property (nonnull, nonatomic, copy) YYTextDebugOption *debugOption;
@@ -372,3 +374,5 @@ IB_DESIGNABLE
 @property (nonatomic) BOOL ignoreCommonProperties;
 @property (nonatomic) BOOL ignoreCommonProperties;
 @end
 @end
 #endif // !TARGET_INTERFACE_BUILDER
 #endif // !TARGET_INTERFACE_BUILDER
+
+NS_ASSUME_NONNULL_END

+ 6 - 6
YYText/YYTextView.h

@@ -21,10 +21,10 @@
 #import "YYTextAttribute.h"
 #import "YYTextAttribute.h"
 #endif
 #endif
 
 
-NS_ASSUME_NONNULL_BEGIN
-
 @class YYTextView;
 @class YYTextView;
 
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
 /**
  The YYTextViewDelegate protocol defines a set of optional methods you can use
  The YYTextViewDelegate protocol defines a set of optional methods you can use
  to receive editing-related messages for YYTextView objects. 
  to receive editing-related messages for YYTextView objects. 
@@ -127,20 +127,20 @@ NS_ASSUME_NONNULL_BEGIN
  When a range of text is detected by the `dataDetectorTypes`, this value would be
  When a range of text is detected by the `dataDetectorTypes`, this value would be
  used to modify the original attributes in the range.
  used to modify the original attributes in the range.
  */
  */
-@property (nullable, nonatomic, copy) NSDictionary *linkTextAttributes;
+@property (nullable, nonatomic, copy) NSDictionary<NSString *, id> *linkTextAttributes;
 
 
 /**
 /**
  The attributes to apply to links at highlight state. Default is a gray border.
  The attributes to apply to links at highlight state. Default is a gray border.
  When a range of text is detected by the `dataDetectorTypes` and the range was touched by user,
  When a range of text is detected by the `dataDetectorTypes` and the range was touched by user,
  this value would be used to modify the original attributes in the range.
  this value would be used to modify the original attributes in the range.
  */
  */
-@property (nullable, nonatomic, copy) NSDictionary *highlightTextAttributes;
+@property (nullable, nonatomic, copy) NSDictionary<NSString *, id> *highlightTextAttributes;
 
 
 /**
 /**
  The attributes to apply to new text being entered by the user.
  The attributes to apply to new text being entered by the user.
  When the text view's selection changes, this value is reset automatically.
  When the text view's selection changes, this value is reset automatically.
  */
  */
-@property (nullable, nonatomic, copy) NSDictionary *typingAttributes;
+@property (nullable, nonatomic, copy) NSDictionary<NSString *, id> *typingAttributes;
 
 
 /**
 /**
  The styled text displayed by the text view.
  The styled text displayed by the text view.
@@ -219,7 +219,7 @@ NS_ASSUME_NONNULL_BEGIN
  An array of UIBezierPath objects representing the exclusion paths inside the 
  An array of UIBezierPath objects representing the exclusion paths inside the 
  receiver's bounding rectangle. Default value is nil.
  receiver's bounding rectangle. Default value is nil.
  */
  */
-@property (nullable, nonatomic, copy) NSArray *exclusionPaths;
+@property (nullable, nonatomic, copy) NSArray<UIBezierPath *> *exclusionPaths;
 
 
 /**
 /**
  Whether the receiver's layout orientation is vertical form. Default is NO.
  Whether the receiver's layout orientation is vertical form. Default is NO.

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно