Skip to content

Commit

Permalink
Safely call the result block
Browse files Browse the repository at this point in the history
  • Loading branch information
LinXunFeng committed Oct 30, 2024
1 parent 36eccd1 commit 2382cf4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ios/Classes/FilePickerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -665,26 +665,32 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)controller
#ifdef PICKER_AUDIO
- (void)mediaPickerDidCancel:(MPMediaPickerController *)controller {
Log(@"FilePicker canceled");
_result(nil);
_result = nil;
if (self.result != nil) {
self.result(nil);
self.result = nil;
}
[controller dismissViewControllerAnimated:YES completion:NULL];
}
#endif // PICKER_AUDIO

#ifdef PICKER_DOCUMENT
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
Log(@"FilePicker canceled");
_result(nil);
_result = nil;
if (self.result != nil) {
self.result(nil);
self.result = nil;
}
[controller dismissViewControllerAnimated:YES completion:NULL];
}
#endif // PICKER_DOCUMENT

#ifdef PICKER_MEDIA
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
Log(@"FilePicker canceled");
_result(nil);
_result = nil;
if (self.result != nil) {
self.result(nil);
self.result = nil;
}
[picker dismissViewControllerAnimated:YES completion:NULL];
}
#endif
Expand Down

0 comments on commit 2382cf4

Please sign in to comment.