Last active
August 29, 2015 14:01
-
-
Save wooster/e6b1d1afa7d0d91da311 to your computer and use it in GitHub Desktop.
Strange CGPDFBoolean Stuff
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
// Simple object, not an array or dictionary. | |
- (void)pushObject:(NSObject *)object withKey:(NSString *)key { | |
NSObject *last = [stack lastObject]; | |
if ([last isKindOfClass:[NSMutableDictionary class]]) { | |
NSMutableDictionary *dictionary = (NSMutableDictionary *)last; | |
// Exception raised here. | |
// *** setObjectForKey: object cannot be nil (key: BaseFont) | |
[dictionary setObject:object forKey:key]; | |
} else if ([last isKindOfClass:[NSMutableArray class]]) { | |
NSMutableArray *array = (NSMutableArray *)last; | |
[array addObject:object]; | |
} | |
} | |
- (void)scanPDFNode:(const char *)cStringKey context:(MMPDFScannerContext *)context object:(CGPDFObjectRef)object dictionary:(CGPDFDictionaryRef)dictionaryRef isArray:(BOOL)isArray { | |
NSString *key = [NSString stringWithUTF8String:cStringKey]; | |
CGPDFObjectType type = CGPDFObjectGetType(object); | |
switch (type) { | |
case kCGPDFObjectTypeNull: | |
[self pushObject:[NSNull null] withKey:key]; | |
break; | |
case kCGPDFObjectTypeBoolean: | |
{ | |
CGPDFBoolean pdfBoolean; | |
if (CGPDFObjectGetValue(object, type, &pdfBoolean)) { | |
// Exception raised inside -pushObject:withKey: from this path. | |
[self pushObject:[NSNumber numberWithBool:(BOOL)pdfBoolean] withKey:key]; | |
} | |
break; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All of this happening inside a CGPDFDictionaryApplyFunction applier function.