Implement readFromURL: in NSMutableAttributedString

This commit is contained in:
ckegel 2023-04-21 11:59:13 -04:00
parent 2f6272f476
commit 7fcfc33365
3 changed files with 28 additions and 21 deletions

View File

@ -203,14 +203,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[self endEditing];
}
- (BOOL) readFromURL:(NSURL *)url
options:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)opts
documentAttributes:(NSDictionary<NSAttributedStringDocumentAttributeKey, id> * _Nullable *)dict
error:(NSError * _Nullable *)error {
NSAttributedString *str = [NSAttributedString alloc];
[str initWithURL:url options:opts documentAttributes:dict error:error];
//[self setAttributedString:str];
NSLog(@"NSMutableAttributedString readFromURL: - hopefully finished reading!");
return true;
- (BOOL) readFromURL: (NSURL *) url
options: (NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *) opts
documentAttributes: (NSDictionary<NSAttributedStringDocumentAttributeKey, id> *_Nullable *) dict
error: (NSError *_Nullable *) error
{
NSAttributedString *str = [NSAttributedString alloc];
str = [str initWithURL: url
options: opts
documentAttributes: dict
error: error];
if (str == nil) {
return NO;
}
[self setAttributedString: str];
[str release];
return YES;
}
@end

View File

@ -258,11 +258,10 @@ enum {
#pragma mark -
#pragma mark Getting Attribute Data
- (void) enumerateAttribute: (NSAttributedStringKey) attrName
inRange: (NSRange) enumerationRange
options: (NSAttributedStringEnumerationOptions) opts
usingBlock:
(void (^)(id value, NSRange range, BOOL *stop)) block;
- (void)enumerateAttribute: (NSAttributedStringKey) attrName
inRange: (NSRange) enumerationRange
options: (NSAttributedStringEnumerationOptions) opts
usingBlock: (void (^)(id value, NSRange range, BOOL *stop)) block;
#pragma mark -
#pragma mark Testing String Data Sources

View File

@ -26,13 +26,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
- (void) fixAttributesInRange: (NSRange) range;
- (void) applyFontTraits: (NSFontTraitMask) traits range: (NSRange) range;
- (BOOL) readFromURL:(NSURL *)url
options:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)opts
documentAttributes:(NSDictionary<NSAttributedStringDocumentAttributeKey, id> * _Nullable *)dict
error:(NSError * _Nullable *)error;
- (BOOL) readFromURL: (NSURL *) url
options: (NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *) opts
documentAttributes: (NSDictionary<NSAttributedStringDocumentAttributeKey, id> * _Nullable *) dict
error: (NSError * _Nullable *)error;
- (void)addAttribute:(NSAttributedStringKey)name
value:(id)value
range:(NSRange)range;
- (void)addAttribute: (NSAttributedStringKey) name
value: (id) value
range: (NSRange) range;
@end