Skip to content

Instantly share code, notes, and snippets.

@m1entus
Created April 30, 2014 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m1entus/9e1579808a2e9ae1f086 to your computer and use it in GitHub Desktop.
Save m1entus/9e1579808a2e9ae1f086 to your computer and use it in GitHub Desktop.
@implementation NSDictionary (QuickLook)
- (id)debugQuickLookObject
{
NSData *data = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:nil];
NSString *JSONString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *embedHTML = [NSString stringWithFormat:@"<html><head></head><body><pre>%@</pre></body></html>",JSONString];
NSURL *temporaryDirectory = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSURL *file = [[temporaryDirectory URLByAppendingPathComponent:@"dictionaryQuickLook"] URLByAppendingPathExtension:@"html"];
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
[embedHTML writeToURL:file atomically:YES encoding:NSUTF8StringEncoding error:nil];
return file;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment