ILPDFKit
ILPDFKit copied to clipboard
Crash while opening a PDF with Forms
For the most cases I'm able to open PDF with forms, but for a special file the app is crashing because of
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance
If find out that the ILPDFFormContainer is the reason for that. Especially in the populateNameTreeNode: method you expect a NSMutableDictionary, but in my case here it is an array:
...
NSMutableDictionary *dict = node[base]; // here in the dict var there comes an array and not dictionary, the base is "1" as STRING
if (dict == nil) {
dict = [NSMutableDictionary dictionary];
node[base] = dict;
}
[self populateNameTreeNode:dict withComponents:[components subarrayWithRange:NSMakeRange(1, [components count]-1)] final:final];
My bad solution was it to check for the class, and in case that it is not a dictionary I don't populate:
NSMutableDictionary *dict = node[base];
if (dict == nil) {
dict = [NSMutableDictionary dictionary];
node[base] = dict;
}
if ([dict isKindOfClass:[NSMutableDictionary class]])
{
[self populateNameTreeNode:dict withComponents:[components subarrayWithRange:NSMakeRange(1, [components count]-1)] final:final];
}