Last active
October 16, 2017 22:05
-
-
Save mjarvis/8345661 to your computer and use it in GitHub Desktop.
This GIST is to help explain the behaviour of NSAttributedString's "initWithData:options:documentAttributes:error:" when used with NSHTMLDocumentType.At first glance, one would expect the output here to be "1, 2, 3", But after some careful reading of the documentation, and if you run the code here, we find that not to be true.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSLog(@"3"); | |
}); | |
NSLog(@"1"); | |
[[NSAttributedString alloc] initWithData:[@"<span>html!</span>" dataUsingEncoding:NSUTF8StringEncoding] | |
options:@{ | |
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, | |
} | |
documentAttributes:nil | |
error:nil]; | |
NSLog(@"2"); | |
/* | |
Expected output: 1 2 3 | |
Actual Output: 1 3 2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment