NSAttributedString(DTCoreText) Category Reference
| Declared in | NSAttributedString+DTCoreText.h |
Tasks
Working with Text Attachments
Calculating Ranges
-
– itemNumberInTextList:atIndex: -
– rangeOfTextList:atIndex: -
– rangeOfTextBlock:atIndex: -
– rangeOfAnchorNamed: -
– rangeOfLinkAtIndex:URL: -
– rangeOfFieldAtIndex:
Converting to Other Representations
Creating Special Attributed Strings
Class Methods
prefixForListItemWithCounter:listStyle:listIndent:attributes:
Create a prefix for a paragraph in a list
+ (NSAttributedString *)prefixForListItemWithCounter:(NSUInteger)listCounter listStyle:(DTCSSListStyle *)listStyle listIndent:(CGFloat)listIndent attributes:(NSDictionary *)attributesParameters
- listCounter
The value for the list item.
- listStyle
The list style
- listIndent
The amount in px to indent the list
- attributes
The attribute dictionary for the text to be prefixed
Return Value
An attributed string with the list prefix
Declared In
NSAttributedString+DTCoreText.hInstance Methods
htmlFragment
Encodes the receiver into a generic HTML fragment representation. Styles are inlined and no html or head tags are included.
- (NSString *)htmlFragmentReturn Value
An HTML string.
Declared In
NSAttributedString+DTCoreText.hhtmlString
Encodes the receiver into a generic HTML prepresentation.
- (NSString *)htmlStringReturn Value
An HTML string.
Declared In
NSAttributedString+DTCoreText.hitemNumberInTextList:atIndex:
Returns the index of the item at the given location within the list.
- (NSInteger)itemNumberInTextList:(DTCSSListStyle *)list atIndex:(NSUInteger)locationParameters
- list
The text list.
- location
The location of the item.
Return Value
Returns the index within the list.
Declared In
NSAttributedString+DTCoreText.hplainTextString
Converts the receiver into plain text.
- (NSString *)plainTextStringReturn Value
The receiver converted to plain text.
Discussion
This is different from the string method of NSAttributedString by also erasing placeholders for text attachments.
Declared In
NSAttributedString+DTCoreText.hrangeOfAnchorNamed:
Returns the range of the given href anchor.
- (NSRange)rangeOfAnchorNamed:(NSString *)anchorNameParameters
- anchorName
The name of the anchor.
Return Value
The range of the given anchor.
Declared In
NSAttributedString+DTCoreText.hrangeOfFieldAtIndex:
Returns the range of a field at the given index.
- (NSRange)rangeOfFieldAtIndex:(NSUInteger)locationParameters
- location
The location of the field
Return Value
The range of the field. If there is no field at this location it returns {NSNotFound, 0}.
Declared In
NSAttributedString+DTCoreText.hrangeOfLinkAtIndex:URL:
Returns the range of the hyperlink at the given index.
- (NSRange)rangeOfLinkAtIndex:(NSUInteger)location URL:(NSURL *__autoreleasing *)URLParameters
- location
The location to query
- URL
The URL that is found at this location or
NULLif this is not needed
Return Value
The range of the given hyperlink.
Declared In
NSAttributedString+DTCoreText.hrangeOfTextBlock:atIndex:
Returns the range of the given text block that contains the given location.
- (NSRange)rangeOfTextBlock:(DTTextBlock *)textBlock atIndex:(NSUInteger)locationParameters
- textBlock
The text block.
- location
The location in the text.
Return Value
The range of the given text block containing the location.
Declared In
NSAttributedString+DTCoreText.hrangeOfTextList:atIndex:
Returns the range of the given text list that contains the given location.
- (NSRange)rangeOfTextList:(DTCSSListStyle *)list atIndex:(NSUInteger)locationParameters
- list
The text list.
- location
The location in the text.
Return Value
The range of the given text list containing the location.
Declared In
NSAttributedString+DTCoreText.htextAttachmentsWithPredicate:class:
Retrieves the DTTextAttachment objects that match the given predicate.
- (NSArray *)textAttachmentsWithPredicate:(NSPredicate *)predicate class:(Class)theClassParameters
- predicate
The predicate to apply for filtering or
nilto not filter by attachment
- theClass
The class that attachments need to have, or
nilfor all attachments regardless of class
Return Value
The filtered array of attachments
Discussion
With this method you can for example find all images that have a certain URL.
Declared In
NSAttributedString+DTCoreText.h