@@ -0,0 +1,17 @@
|
||||
//
|
||||
// HTMLComment.h
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 25/02/15.
|
||||
// Copyright (c) 2015 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HTMLNode.h"
|
||||
|
||||
@interface HTMLComment : HTMLNode
|
||||
|
||||
@property (nonatomic, copy) NSString *data;
|
||||
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// HTMLComment.m
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 25/02/15.
|
||||
// Copyright (c) 2015 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HTMLComment.h"
|
||||
|
||||
@implementation HTMLComment
|
||||
|
||||
- (instancetype)initWithData:(NSString *)data
|
||||
{
|
||||
self = [super initWithName:@"#comment" type:HTMLCommentNode];
|
||||
if (self) {
|
||||
self.data = data ?: @"";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)textContent
|
||||
{
|
||||
return self.data;
|
||||
}
|
||||
|
||||
- (void)setTextContent:(NSString *)textContent
|
||||
{
|
||||
self.data = textContent ?: @"";
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
HTMLComment *copy = [super copyWithZone:zone];
|
||||
copy.data = self.data;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@end
|
||||
+2
-2
@@ -51,10 +51,10 @@ typedef NS_ENUM(short, HTMLNodeType)
|
||||
|
||||
@property (nonatomic, strong, readonly) HTMLNode *nextSibling;
|
||||
|
||||
@property (nonatomic, copy) NSString *value;
|
||||
|
||||
@property (nonatomic, copy) NSString *textContent;
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type;
|
||||
|
||||
- (BOOL)hasChildNodes;
|
||||
|
||||
- (HTMLNode *)childNodeAtIndex:(NSUInteger)index;
|
||||
|
||||
Reference in New Issue
Block a user