Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Sep 17, 2024
1 parent dc02e91 commit 345097c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions TweakLoader/DocumentPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ @implementation UIDocumentPickerViewController(LiveContainerHook)

- (instancetype)hook_initForOpeningContentTypes:(NSArray<UTType *> *)contentTypes asCopy:(BOOL)asCopy {

// if app is going to choose any unrecognized file type, then we replace it with @[UTTypeItem, UTTypeFolder];
NSArray<UTType *> * contentTypesNew = contentTypes;
for(UTType* type in contentTypes) {
if(!type) {
contentTypesNew = @[UTTypeItem, UTTypeFolder];
break;
}
}

// prevent crash when selecting only folder
BOOL shouldMultiselect = NO;

if (fixFilePicker && [contentTypes count] == 1 && contentTypes[0] == UTTypeFolder) {
contentTypesNew = @[UTTypeItem, UTTypeFolder];
shouldMultiselect = YES;
}

// if app is going to choose any unrecognized file type, then we replace it with @[UTTypeItem, UTTypeFolder];
NSArray<UTType *> * contentTypesNew = @[UTTypeItem, UTTypeFolder];



if(fixFilePicker) {
UIDocumentPickerViewController* ans = [self hook_initForOpeningContentTypes:contentTypesNew asCopy:YES];
if(shouldMultiselect) {
Expand Down

0 comments on commit 345097c

Please sign in to comment.