Skip to content

Commit d663912

Browse files
committed
Fixed warnings
1 parent 6233cee commit d663912

File tree

8 files changed

+198
-188
lines changed

8 files changed

+198
-188
lines changed

Alpha/Asset/Cache/ALPHACache.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PINCache is a modified version of TMCache
1+
// ALPHACache is a modified version of PINCache
22
// Modifications by Garrett Moon
33
// Copyright (c) 2015 Pinterest. All rights reserved.
44

@@ -15,13 +15,13 @@ NS_ASSUME_NONNULL_BEGIN
1515
A callback block which provides only the cache as an argument
1616
*/
1717

18-
typedef void (^PINCacheBlock)(ALPHACache *cache);
18+
typedef void (^ALPHACacheBlock)(ALPHACache *cache);
1919

2020
/**
2121
A callback block which provides the cache, key and object as arguments
2222
*/
2323

24-
typedef void (^PINCacheObjectBlock)(ALPHACache *cache, NSString *key, id __nullable object);
24+
typedef void (^ALPHACacheObjectBlock)(ALPHACache *cache, NSString *key, id __nullable object);
2525

2626
/**
2727
`ALPHACache` is a thread safe key/value store designed for persisting temporary objects that are expensive to
@@ -111,7 +111,7 @@ typedef void (^PINCacheObjectBlock)(ALPHACache *cache, NSString *key, id __nulla
111111
@param key The key associated with the requested object.
112112
@param block A block to be executed concurrently when the object is available.
113113
*/
114-
- (void)objectForKey:(NSString *)key block:(PINCacheObjectBlock)block;
114+
- (void)objectForKey:(NSString *)key block:(ALPHACacheObjectBlock)block;
115115

116116
/**
117117
Stores an object in the cache for the specified key. This method returns immediately and executes the
@@ -121,7 +121,7 @@ typedef void (^PINCacheObjectBlock)(ALPHACache *cache, NSString *key, id __nulla
121121
@param key A key to associate with the object. This string will be copied.
122122
@param block A block to be executed concurrently after the object has been stored, or nil.
123123
*/
124-
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(nullable PINCacheObjectBlock)block;
124+
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(nullable ALPHACacheObjectBlock)block;
125125

126126
/**
127127
Removes the object for the specified key. This method returns immediately and executes the passed
@@ -130,7 +130,7 @@ typedef void (^PINCacheObjectBlock)(ALPHACache *cache, NSString *key, id __nulla
130130
@param key The key associated with the object to be removed.
131131
@param block A block to be executed concurrently after the object has been removed, or nil.
132132
*/
133-
- (void)removeObjectForKey:(NSString *)key block:(nullable PINCacheObjectBlock)block;
133+
- (void)removeObjectForKey:(NSString *)key block:(nullable ALPHACacheObjectBlock)block;
134134

135135
/**
136136
Removes all objects from the cache that have not been used since the specified date. This method returns immediately and
@@ -139,15 +139,15 @@ typedef void (^PINCacheObjectBlock)(ALPHACache *cache, NSString *key, id __nulla
139139
@param date Objects that haven't been accessed since this date are removed from the cache.
140140
@param block A block to be executed concurrently after the cache has been trimmed, or nil.
141141
*/
142-
- (void)trimToDate:(NSDate *)date block:(nullable PINCacheBlock)block;
142+
- (void)trimToDate:(NSDate *)date block:(nullable ALPHACacheBlock)block;
143143

144144
/**
145145
Removes all objects from the cache.This method returns immediately and executes the passed block after the
146146
cache has been cleared, potentially in parallel with other blocks on the <concurrentQueue>.
147147
148148
@param block A block to be executed concurrently after the cache has been cleared, or nil.
149149
*/
150-
- (void)removeAllObjects:(nullable PINCacheBlock)block;
150+
- (void)removeAllObjects:(nullable ALPHACacheBlock)block;
151151

152152
#pragma mark -
153153
/// @name Synchronous Methods

Alpha/Asset/Cache/ALPHACache.m

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// PINCache is a modified version of PINCache
1+
// ALPHACache is a modified version of ALPHACache
22
// Modifications by Garrett Moon
33
// Copyright (c) 2015 Pinterest. All rights reserved.
44

55
#import "ALPHACache.h"
66

7-
NSString * const PINCachePrefix = @"com.unifiedsense.alpha.AssetCacheShared";
8-
NSString * const PINCacheSharedName = @"ALPHAAssetCacheShared";
7+
NSString * const ALPHACachePrefix = @"com.unifiedsense.alpha.AssetCacheShared";
8+
NSString * const ALPHACacheSharedName = @"ALPHAAssetCacheShared";
99

1010
@interface ALPHACache ()
1111
#if OS_OBJECT_USE_OBJC
@@ -27,6 +27,11 @@ - (void)dealloc
2727
}
2828
#endif
2929

30+
- (instancetype)init
31+
{
32+
return [self initWithName:@"com.unifiedsense.Alpha"];
33+
}
34+
3035
- (instancetype)initWithName:(NSString *)name
3136
{
3237
return [self initWithName:name rootPath:[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]];
@@ -40,7 +45,7 @@ - (instancetype)initWithName:(NSString *)name rootPath:(NSString *)rootPath
4045
if (self = [super init]) {
4146
_name = [name copy];
4247

43-
NSString *queueName = [[NSString alloc] initWithFormat:@"%@.%p", PINCachePrefix, self];
48+
NSString *queueName = [[NSString alloc] initWithFormat:@"%@.%p", ALPHACachePrefix, self];
4449
_concurrentQueue = dispatch_queue_create([[NSString stringWithFormat:@"%@ Asynchronous Queue", queueName] UTF8String], DISPATCH_QUEUE_CONCURRENT);
4550

4651
_diskCache = [[ALPHADiskCache alloc] initWithName:_name rootPath:rootPath];
@@ -51,7 +56,7 @@ - (instancetype)initWithName:(NSString *)name rootPath:(NSString *)rootPath
5156

5257
- (NSString *)description
5358
{
54-
return [[NSString alloc] initWithFormat:@"%@.%@.%p", PINCachePrefix, _name, self];
59+
return [[NSString alloc] initWithFormat:@"%@.%@.%p", ALPHACachePrefix, _name, self];
5560
}
5661

5762
+ (instancetype)sharedCache
@@ -60,7 +65,7 @@ + (instancetype)sharedCache
6065
static dispatch_once_t predicate;
6166

6267
dispatch_once(&predicate, ^{
63-
cache = [[self alloc] initWithName:PINCacheSharedName];
68+
cache = [[self alloc] initWithName:ALPHACacheSharedName];
6469
});
6570

6671
return cache;
@@ -69,7 +74,7 @@ + (instancetype)sharedCache
6974
#pragma mark - Public Asynchronous Methods -
7075

7176

72-
- (void)objectForKey:(NSString *)key block:(PINCacheObjectBlock)block
77+
- (void)objectForKey:(NSString *)key block:(ALPHACacheObjectBlock)block
7378
{
7479
if (!key || !block)
7580
return;
@@ -123,14 +128,14 @@ - (void)objectForKey:(NSString *)key block:(PINCacheObjectBlock)block
123128
});
124129
}
125130

126-
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(PINCacheObjectBlock)block
131+
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(ALPHACacheObjectBlock)block
127132
{
128133
if (!key || !object)
129134
return;
130135

131136
dispatch_group_t group = nil;
132-
PINMemoryCacheObjectBlock memBlock = nil;
133-
PINDiskCacheObjectBlock diskBlock = nil;
137+
ALPHAMemoryCacheObjectBlock memBlock = nil;
138+
ALPHADiskCacheObjectBlock diskBlock = nil;
134139

135140
if (block) {
136141
group = dispatch_group_create();
@@ -163,14 +168,14 @@ - (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(PINCacheOb
163168
}
164169
}
165170

166-
- (void)removeObjectForKey:(NSString *)key block:(PINCacheObjectBlock)block
171+
- (void)removeObjectForKey:(NSString *)key block:(ALPHACacheObjectBlock)block
167172
{
168173
if (!key)
169174
return;
170175

171176
dispatch_group_t group = nil;
172-
PINMemoryCacheObjectBlock memBlock = nil;
173-
PINDiskCacheObjectBlock diskBlock = nil;
177+
ALPHAMemoryCacheObjectBlock memBlock = nil;
178+
ALPHADiskCacheObjectBlock diskBlock = nil;
174179

175180
if (block) {
176181
group = dispatch_group_create();
@@ -203,11 +208,11 @@ - (void)removeObjectForKey:(NSString *)key block:(PINCacheObjectBlock)block
203208
}
204209
}
205210

206-
- (void)removeAllObjects:(PINCacheBlock)block
211+
- (void)removeAllObjects:(ALPHACacheBlock)block
207212
{
208213
dispatch_group_t group = nil;
209-
PINMemoryCacheBlock memBlock = nil;
210-
PINDiskCacheBlock diskBlock = nil;
214+
ALPHAMemoryCacheBlock memBlock = nil;
215+
ALPHADiskCacheBlock diskBlock = nil;
211216

212217
if (block) {
213218
group = dispatch_group_create();
@@ -240,14 +245,14 @@ - (void)removeAllObjects:(PINCacheBlock)block
240245
}
241246
}
242247

243-
- (void)trimToDate:(NSDate *)date block:(PINCacheBlock)block
248+
- (void)trimToDate:(NSDate *)date block:(ALPHACacheBlock)block
244249
{
245250
if (!date)
246251
return;
247252

248253
dispatch_group_t group = nil;
249-
PINMemoryCacheBlock memBlock = nil;
250-
PINDiskCacheBlock diskBlock = nil;
254+
ALPHAMemoryCacheBlock memBlock = nil;
255+
ALPHADiskCacheBlock diskBlock = nil;
251256

252257
if (block) {
253258
group = dispatch_group_create();

Alpha/Asset/Cache/ALPHADiskCache.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PINCache is a modified version of TMCache
1+
// ALPHACache is a modified version of TMCache
22
// Modifications by Garrett Moon
33
// Copyright (c) 2015 Pinterest. All rights reserved.
44

@@ -14,13 +14,13 @@ NS_ASSUME_NONNULL_BEGIN
1414
A callback block which provides only the cache as an argument
1515
*/
1616

17-
typedef void (^PINDiskCacheBlock)(ALPHADiskCache *cache);
17+
typedef void (^ALPHADiskCacheBlock)(ALPHADiskCache *cache);
1818

1919
/**
2020
A callback block which provides the cache, key and object as arguments
2121
*/
2222

23-
typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id <NSCoding> __nullable object, NSURL *fileURL);
23+
typedef void (^ALPHADiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id <NSCoding> __nullable object, NSURL *fileURL);
2424

2525
/**
2626
`ALPHADiskCache` is a thread safe key/value store backed by the file system. It accepts any object conforming
@@ -104,34 +104,34 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
104104
/**
105105
A block to be executed just before an object is added to the cache. The queue waits during execution.
106106
*/
107-
@property (copy) PINDiskCacheObjectBlock __nullable willAddObjectBlock;
107+
@property (copy) ALPHADiskCacheObjectBlock __nullable willAddObjectBlock;
108108

109109
/**
110110
A block to be executed just before an object is removed from the cache. The queue waits during execution.
111111
*/
112-
@property (copy) PINDiskCacheObjectBlock __nullable willRemoveObjectBlock;
112+
@property (copy) ALPHADiskCacheObjectBlock __nullable willRemoveObjectBlock;
113113

114114
/**
115115
A block to be executed just before all objects are removed from the cache as a result of <removeAllObjects:>.
116116
The queue waits during execution.
117117
*/
118-
@property (copy) PINDiskCacheBlock __nullable willRemoveAllObjectsBlock;
118+
@property (copy) ALPHADiskCacheBlock __nullable willRemoveAllObjectsBlock;
119119

120120
/**
121121
A block to be executed just after an object is added to the cache. The queue waits during execution.
122122
*/
123-
@property (copy) PINDiskCacheObjectBlock __nullable didAddObjectBlock;
123+
@property (copy) ALPHADiskCacheObjectBlock __nullable didAddObjectBlock;
124124

125125
/**
126126
A block to be executed just after an object is removed from the cache. The queue waits during execution.
127127
*/
128-
@property (copy) PINDiskCacheObjectBlock __nullable didRemoveObjectBlock;
128+
@property (copy) ALPHADiskCacheObjectBlock __nullable didRemoveObjectBlock;
129129

130130
/**
131131
A block to be executed just after all objects are removed from the cache as a result of <removeAllObjects:>.
132132
The queue waits during execution.
133133
*/
134-
@property (copy) PINDiskCacheBlock __nullable didRemoveAllObjectsBlock;
134+
@property (copy) ALPHADiskCacheBlock __nullable didRemoveAllObjectsBlock;
135135

136136
#pragma mark -
137137
/// @name Initialization
@@ -179,7 +179,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
179179
180180
@param block A block to be executed when a lock is available.
181181
*/
182-
- (void)lockFileAccessWhileExecutingBlock:(nullable PINDiskCacheBlock)block;
182+
- (void)lockFileAccessWhileExecutingBlock:(nullable ALPHADiskCacheBlock)block;
183183

184184
/**
185185
Retrieves the object for the specified key. This method returns immediately and executes the passed
@@ -190,7 +190,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
190190
@param key The key associated with the requested object.
191191
@param block A block to be executed serially when the object is available.
192192
*/
193-
- (void)objectForKey:(NSString *)key block:(nullable PINDiskCacheObjectBlock)block;
193+
- (void)objectForKey:(NSString *)key block:(nullable ALPHADiskCacheObjectBlock)block;
194194

195195
/**
196196
Retrieves the fileURL for the specified key without actually reading the data from disk. This method
@@ -202,7 +202,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
202202
@param key The key associated with the requested object.
203203
@param block A block to be executed serially when the file URL is available.
204204
*/
205-
- (void)fileURLForKey:(nullable NSString *)key block:(nullable PINDiskCacheObjectBlock)block;
205+
- (void)fileURLForKey:(nullable NSString *)key block:(nullable ALPHADiskCacheObjectBlock)block;
206206

207207
/**
208208
Stores an object in the cache for the specified key. This method returns immediately and executes the
@@ -212,7 +212,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
212212
@param key A key to associate with the object. This string will be copied.
213213
@param block A block to be executed serially after the object has been stored, or nil.
214214
*/
215-
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(nullable PINDiskCacheObjectBlock)block;
215+
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key block:(nullable ALPHADiskCacheObjectBlock)block;
216216

217217
/**
218218
Removes the object for the specified key. This method returns immediately and executes the passed block
@@ -221,7 +221,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
221221
@param key The key associated with the object to be removed.
222222
@param block A block to be executed serially after the object has been removed, or nil.
223223
*/
224-
- (void)removeObjectForKey:(NSString *)key block:(nullable PINDiskCacheObjectBlock)block;
224+
- (void)removeObjectForKey:(NSString *)key block:(nullable ALPHADiskCacheObjectBlock)block;
225225

226226
/**
227227
Removes all objects from the cache that have not been used since the specified date.
@@ -230,7 +230,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
230230
@param date Objects that haven't been accessed since this date are removed from the cache.
231231
@param block A block to be executed serially after the cache has been trimmed, or nil.
232232
*/
233-
- (void)trimToDate:(NSDate *)date block:(nullable PINDiskCacheBlock)block;
233+
- (void)trimToDate:(NSDate *)date block:(nullable ALPHADiskCacheBlock)block;
234234

235235
/**
236236
Removes objects from the cache, largest first, until the cache is equal to or smaller than the specified byteCount.
@@ -239,7 +239,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
239239
@param byteCount The cache will be trimmed equal to or smaller than this size.
240240
@param block A block to be executed serially after the cache has been trimmed, or nil.
241241
*/
242-
- (void)trimToSize:(NSUInteger)byteCount block:(nullable PINDiskCacheBlock)block;
242+
- (void)trimToSize:(NSUInteger)byteCount block:(nullable ALPHADiskCacheBlock)block;
243243

244244
/**
245245
Removes objects from the cache, ordered by date (least recently used first), until the cache is equal to or smaller
@@ -249,15 +249,15 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
249249
@param byteCount The cache will be trimmed equal to or smaller than this size.
250250
@param block A block to be executed serially after the cache has been trimmed, or nil.
251251
*/
252-
- (void)trimToSizeByDate:(NSUInteger)byteCount block:(nullable PINDiskCacheBlock)block;
252+
- (void)trimToSizeByDate:(NSUInteger)byteCount block:(nullable ALPHADiskCacheBlock)block;
253253

254254
/**
255255
Removes all objects from the cache. This method returns immediately and executes the passed block as soon as the
256256
cache has been cleared.
257257
258258
@param block A block to be executed serially after the cache has been cleared, or nil.
259259
*/
260-
- (void)removeAllObjects:(nullable PINDiskCacheBlock)block;
260+
- (void)removeAllObjects:(nullable ALPHADiskCacheBlock)block;
261261

262262
/**
263263
Loops through all objects in the cache (reads and writes are suspended during the enumeration). Data is not actually
@@ -267,7 +267,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
267267
@param block A block to be executed for every object in the cache.
268268
@param completionBlock An optional block to be executed after the enumeration is complete.
269269
*/
270-
- (void)enumerateObjectsWithBlock:(PINDiskCacheObjectBlock)block completionBlock:(nullable PINDiskCacheBlock)completionBlock;
270+
- (void)enumerateObjectsWithBlock:(ALPHADiskCacheObjectBlock)block completionBlock:(nullable ALPHADiskCacheBlock)completionBlock;
271271

272272
#pragma mark -
273273
/// @name Synchronous Methods
@@ -280,7 +280,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
280280
281281
@param block A block to be executed when a lock is available.
282282
*/
283-
- (void)synchronouslyLockFileAccessWhileExecutingBlock:(nullable PINDiskCacheBlock)block;
283+
- (void)synchronouslyLockFileAccessWhileExecutingBlock:(nullable ALPHADiskCacheBlock)block;
284284

285285
/**
286286
Retrieves the object for the specified key. This method blocks the calling thread until the
@@ -356,7 +356,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
356356
@warning Do not call this method within the event blocks (<didRemoveObjectBlock>, etc.)
357357
Instead use the asynchronous version, <enumerateObjectsWithBlock:completionBlock:>.
358358
*/
359-
- (void)enumerateObjectsWithBlock:(nullable PINDiskCacheObjectBlock)block;
359+
- (void)enumerateObjectsWithBlock:(nullable ALPHADiskCacheObjectBlock)block;
360360

361361
@end
362362

0 commit comments

Comments
 (0)