diff --git a/Sources/SPTPersistentCache.m b/Sources/SPTPersistentCache.m index 3dc480c..3618b17 100644 --- a/Sources/SPTPersistentCache.m +++ b/Sources/SPTPersistentCache.m @@ -79,6 +79,11 @@ - (instancetype)init return [self initWithOptions:[SPTPersistentCacheOptions new]]; } +- (nullable instancetype)initFailableWithOptions:(SPTPersistentCacheOptions *)options +{ + return [self initWithOptions:options]; +} + - (instancetype)initWithOptions:(SPTPersistentCacheOptions *)options { self = [super init]; diff --git a/Tests/SPTPersistentCacheTests.m b/Tests/SPTPersistentCacheTests.m index ad297af..2e64b1e 100644 --- a/Tests/SPTPersistentCacheTests.m +++ b/Tests/SPTPersistentCacheTests.m @@ -1270,7 +1270,7 @@ - (void)testInitNilWhenCannotCreateCacheDirectory return nil; }); method_setImplementation(originalMethod, fakeMethodImplementation); - SPTPersistentCache *cache = [[SPTPersistentCache alloc] initWithOptions:options]; + SPTPersistentCache *cache = [[SPTPersistentCache alloc] initFailableWithOptions:options]; method_setImplementation(originalMethod, originalMethodImplementation); XCTAssertNil(cache, @"The cache should be nil if it could not create the directory"); diff --git a/include/SPTPersistentCache/SPTPersistentCacheImplementation.h b/include/SPTPersistentCache/SPTPersistentCacheImplementation.h index a1b537b..3471d26 100644 --- a/include/SPTPersistentCache/SPTPersistentCacheImplementation.h +++ b/include/SPTPersistentCache/SPTPersistentCacheImplementation.h @@ -107,6 +107,13 @@ typedef NSString * _Nonnull(^SPTPersistentCacheChooseKeyCallback)(NSArray