From 744497d7601d533181637fdde1f9f640cd3bf081 Mon Sep 17 00:00:00 2001 From: Hunter Mask Date: Tue, 28 Feb 2017 16:41:44 -0500 Subject: [PATCH] Add nullability specification --- BRYHTMLParser/HTMLNode.h | 34 +++++++++++++++++----------------- BRYHTMLParser/HTMLParser.h | 14 +++++++------- BRYHTMLParser/LibXMLHTMLNode.h | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/BRYHTMLParser/HTMLNode.h b/BRYHTMLParser/HTMLNode.h index fd79e82..f9e4112 100644 --- a/BRYHTMLParser/HTMLNode.h +++ b/BRYHTMLParser/HTMLNode.h @@ -40,57 +40,57 @@ typedef NS_ENUM(unsigned int, HTMLNodeType) { @protocol HTMLNode /// Returns the first child element -@property (nonatomic, readonly) id firstChild; +@property (nonatomic, readonly, nullable) id firstChild; /// Returns the plaintext contents of node -@property (nonatomic, readonly, copy) NSString *contents; +@property (nonatomic, readonly, copy, nullable) NSString *contents; /// Returns the plaintext contents of this node + all children -@property (nonatomic, readonly, copy) NSString *allContents; +@property (nonatomic, readonly, copy, nullable) NSString *allContents; /// Returns the html contents of the node -@property (nonatomic, readonly, copy) NSString *rawContents; +@property (nonatomic, readonly, copy, nullable) NSString *rawContents; /// Returns next sibling in tree -@property (nonatomic, readonly) id nextSibling; +@property (nonatomic, readonly, nullable) id nextSibling; /// Returns previous sibling in tree -@property (nonatomic, readonly) id previousSibling; +@property (nonatomic, readonly, nullable) id previousSibling; /// Returns the class name -@property (nonatomic, readonly, copy) NSString *className; +@property (nonatomic, readonly, copy, nullable) NSString *className; /// Returns the tag name -@property (nonatomic, readonly, copy) NSString *tagName; +@property (nonatomic, readonly, copy, nullable) NSString *tagName; /// Returns the parent -@property (nonatomic, readonly) id parent; +@property (nonatomic, readonly, nullable) id parent; /// Returns the first level of children -@property (nonatomic, readonly, copy) NSArray *children; +@property (nonatomic, readonly, copy, nonnull) NSArray> *children; /// Returns the node type if know @property (nonatomic, readonly) HTMLNodeType nodetype; /// Gets the attribute value matching tha name -- (NSString *)getAttributeNamed:(NSString *)name; +- (nullable NSString *)getAttributeNamed:(nonnull NSString *)name; /// Find children with the specified tag name -- (NSArray *)findChildTags:(NSString *)tagName; +- (nonnull NSArray> *)findChildTags:(nonnull NSString *)tagName; /// Looks for a tag name e.g. "h3" -- (id )findChildTag:(NSString *)tagName; +- (nullable id )findChildTag:(nonnull NSString *)tagName; /// Returns a single child of class -- (id )findChildOfClass:(NSString *)className; +- (nullable id )findChildOfClass:(nonnull NSString *)className; /// Returns all children of class -- (NSArray *)findChildrenOfClass:(NSString *)className; +- (nonnull NSArray> *)findChildrenOfClass:(nonnull NSString *)className; /// Finds a single child with a matching attribute. Set `allowPartial` to match partial matches, e.g. )findChildWithAttribute:(NSString *)attribute matchingName:(NSString *)className allowPartial:(BOOL)partial; +- (nullable id )findChildWithAttribute:(nonnull NSString *)attribute matchingName:(nonnull NSString *)className allowPartial:(BOOL)partial; /// Finds all children with a matching attribute -- (NSArray *)findChildrenWithAttribute:(NSString *)attribute matchingName:(NSString *)className allowPartial:(BOOL)partial; +- (nonnull NSArray> *)findChildrenWithAttribute:(nonnull NSString *)attribute matchingName:(nonnull NSString *)className allowPartial:(BOOL)partial; @end diff --git a/BRYHTMLParser/HTMLParser.h b/BRYHTMLParser/HTMLParser.h index f8242d2..96bd89e 100644 --- a/BRYHTMLParser/HTMLParser.h +++ b/BRYHTMLParser/HTMLParser.h @@ -12,21 +12,21 @@ @interface HTMLParser : NSObject /// Returns the doc tag -@property (nonatomic, readonly) id doc; +@property (nonatomic, readonly, nullable) id doc; /// Returns the body tag -@property (nonatomic, readonly) id body; +@property (nonatomic, readonly, nullable) id body; /// Returns the html tag -@property (nonatomic, readonly) id html; +@property (nonatomic, readonly, nullable) id html; /// Returns the head tag -@property (nonatomic, readonly) id head; +@property (nonatomic, readonly, nullable) id head; -- (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError **)error; +- (nullable instancetype)initWithContentsOfURL:(nonnull NSURL *)url error:(NSError * _Nullable * _Nullable)error; -- (instancetype)initWithData:(NSData *)data error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype)initWithData:(nonnull NSData *)data error:(NSError * _Nullable * _Nullable)error NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithString:(NSString *)string error:(NSError **)error NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype)initWithString:(nonnull NSString *)string error:(NSError * _Nullable * _Nullable)error NS_DESIGNATED_INITIALIZER; @end diff --git a/BRYHTMLParser/LibXMLHTMLNode.h b/BRYHTMLParser/LibXMLHTMLNode.h index 9c90cd6..ac27def 100644 --- a/BRYHTMLParser/LibXMLHTMLNode.h +++ b/BRYHTMLParser/LibXMLHTMLNode.h @@ -14,6 +14,6 @@ struct _xmlNode; /// Init with a lib xml node (shouldn't need to be called manually). Use [parser doc] to get the root Node -- (instancetype)initWithXMLNode:(struct _xmlNode *)xmlNode NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype)initWithXMLNode:(struct _xmlNode * _Nullable)xmlNode NS_DESIGNATED_INITIALIZER; @end