Files
yattee/Yattee/Helpers/ObjCExceptionHandler.h
Arkadiusz Fal 13614e7fa0 Fix CFNetwork SIGABRT crash when creating download tasks on invalidated session
The background URLSession could be in an invalid state when downloadTask(with:)
is called, because invalidateAndCancel() is asynchronous internally. This adds
an ObjC exception handler to catch NSExceptions from CFNetwork, nil guards on
the session, and safer session lifecycle management (nil after invalidation,
finishTasksAndInvalidate for cellular toggle).
2026-02-19 17:25:14 +01:00

18 lines
527 B
Objective-C

//
// ObjCExceptionHandler.h
// Yattee
//
// Catches ObjC NSExceptions that Swift cannot handle natively.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Executes a block and catches any NSException thrown.
/// Returns YES if the block executed without throwing, NO if an exception was caught.
/// If an exception is caught, it is returned via the outException parameter.
BOOL tryCatchObjCException(void (NS_NOESCAPE ^block)(void), NSException *_Nullable *_Nullable outException);
NS_ASSUME_NONNULL_END