forked from veryweblog/ichm
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathCHMDocumentController.m
62 lines (38 loc) · 1.37 KB
/
CHMDocumentController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// CHMDocumentController.m
// ichm
//
// Created by Mark Douma on 5/26/2016.
// Copyright © 2016 Mark Douma LLC. All rights reserved.
//
#import "CHMDocumentController.h"
#import "CHMBookmark.h"
#import "CHMDocument.h"
#define MD_DEBUG 0
#if MD_DEBUG
#define MDLog(...) NSLog(__VA_ARGS__)
#else
#define MDLog(...)
#endif
@interface CHMDocumentController ()
@property (nonatomic, retain) CHMBookmark *pendingBookmarkToLoad;
@end
@implementation CHMDocumentController
@synthesize pendingBookmarkToLoad;
- (void)dealloc {
[pendingBookmarkToLoad release];
[super dealloc];
}
- (id)openDocumentWithContentsOfURL:(NSURL *)URL loadBookmark:(CHMBookmark *)bookmark error:(NSError **)outError {
self.pendingBookmarkToLoad = bookmark;
return [super openDocumentWithContentsOfURL:URL display:YES error:outError];
}
- (id)makeDocumentWithContentsOfURL:(NSURL *)URL ofType:(NSString *)typeName error:(NSError **)outError {
MDLog(@"[%@ %@] URL.path == %@; type == %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), URL.path, typeName);
if (pendingBookmarkToLoad == nil) return [super makeDocumentWithContentsOfURL:URL ofType:typeName error:outError];
CHMDocument *document = [super makeDocumentWithContentsOfURL:URL ofType:typeName error:outError];
document.pendingBookmarkToLoad = pendingBookmarkToLoad;
self.pendingBookmarkToLoad = nil;
return document;
}
@end