Преглед на файлове

swift api compatibility

ibireme преди 9 години
родител
ревизия
3b333af3ad
променени са 7 файла, в които са добавени 87 реда и са изтрити 72 реда
  1. 17 14
      YYCache/YYCache.h
  2. 1 1
      YYCache/YYCache.m
  3. 24 20
      YYCache/YYDiskCache.h
  4. 2 2
      YYCache/YYDiskCache.m
  5. 24 20
      YYCache/YYKVStorage.h
  6. 1 1
      YYCache/YYKVStorage.m
  7. 18 14
      YYCache/YYMemoryCache.h

+ 17 - 14
YYCache/YYCache.h

@@ -27,6 +27,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
 #import "YYKVStorage.h"
 #endif
 
+NS_ASSUME_NONNULL_BEGIN
 
 
 /**
@@ -56,17 +57,17 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
      read and write to this directory.
  @result A new cache object, or nil if an error occurs.
  */
-- (instancetype)initWithName:(NSString *)name;
+- (nullable instancetype)initWithName:(NSString *)name;
 
 /**
- Create a new instance with the specified name.
+ Create a new instance with the specified path.
  Multiple instances with the same name will make the cache unstable.
  
  @param path  Full path of a directory in which the cache will write data.
      Once initialized you should not read and write to this directory.
  @result A new cache object, or nil if an error occurs.
  */
-- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
+- (nullable instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
 
 /**
  Convenience Initializers
@@ -78,18 +79,18 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
      read and write to this directory.
  @result A new cache object, or nil if an error occurs.
  */
-+ (instancetype)cacheWithName:(NSString *)name;
++ (nullable instancetype)cacheWithName:(NSString *)name;
 
 /**
  Convenience Initializers
- Create a new instance with the specified name.
+ Create a new instance with the specified path.
  Multiple instances with the same name will make the cache unstable.
  
  @param path  Full path of a directory in which the cache will write data.
      Once initialized you should not read and write to this directory.
  @result A new cache object, or nil if an error occurs.
  */
-+ (instancetype)cacheWithPath:(NSString *)path;
++ (nullable instancetype)cacheWithPath:(NSString *)path;
 
 - (instancetype)init UNAVAILABLE_ATTRIBUTE;
 + (instancetype)new UNAVAILABLE_ATTRIBUTE;
@@ -116,7 +117,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param key   A string identifying the value. If nil, just return NO.
  @param block A block which will be invoked in background queue when finished.
  */
-- (void)containsObjectForKey:(NSString *)key withBlock:(void(^)(NSString *key, BOOL contains))block;
+- (void)containsObjectForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key, BOOL contains))block;
 
 /**
  Returns the value associated with a given key.
@@ -125,7 +126,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param key A string identifying the value. If nil, just return nil.
  @return The value associated with key, or nil if no value is associated with key.
  */
-- (id<NSCoding>)objectForKey:(NSString *)key;
+- (nullable id<NSCoding>)objectForKey:(NSString *)key;
 
 /**
  Returns the value associated with a given key.
@@ -135,7 +136,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param key A string identifying the value. If nil, just return nil.
  @param block A block which will be invoked in background queue when finished.
  */
-- (void)objectForKey:(NSString *)key withBlock:(void(^)(NSString *key, id<NSCoding> object))block;
+- (void)objectForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key, id<NSCoding> object))block;
 
 /**
  Sets the value of the specified key in the cache.
@@ -144,7 +145,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`.
  @param key    The key with which to associate the value. If nil, this method has no effect.
  */
-- (void)setObject:(id<NSCoding>)object forKey:(NSString *)key;
+- (void)setObject:(nullable id<NSCoding>)object forKey:(NSString *)key;
 
 /**
  Sets the value of the specified key in the cache.
@@ -154,7 +155,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`.
  @param block  A block which will be invoked in background queue when finished.
  */
-- (void)setObject:(id<NSCoding>)object forKey:(NSString *)key withBlock:(void(^)(void))block;
+- (void)setObject:(nullable id<NSCoding>)object forKey:(NSString *)key withBlock:(nullable void(^)(void))block;
 
 /**
  Removes the value of the specified key in the cache.
@@ -172,7 +173,7 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param key The key identifying the value to be removed. If nil, this method has no effect.
  @param block  A block which will be invoked in background queue when finished.
  */
-- (void)removeObjectForKey:(NSString *)key withBlock:(void(^)(NSString *key))block;
+- (void)removeObjectForKey:(NSString *)key withBlock:(nullable void(^)(NSString *key))block;
 
 /**
  Empties the cache.
@@ -197,7 +198,9 @@ FOUNDATION_EXPORT const unsigned char YYCacheVersionString[];
  @param progress This block will be invoked during removing, pass nil to ignore.
  @param end      This block will be invoked at the end, pass nil to ignore.
  */
-- (void)removeAllObjectsWithProgressBlock:(void(^)(int removedCount, int totalCount))progress
-                                 endBlock:(void(^)(BOOL error))end;
+- (void)removeAllObjectsWithProgressBlock:(nullable void(^)(int removedCount, int totalCount))progress
+                                 endBlock:(nullable void(^)(BOOL error))end;
 
 @end
+
+NS_ASSUME_NONNULL_END

+ 1 - 1
YYCache/YYCache.m

@@ -17,7 +17,7 @@
 
 - (instancetype) init {
     NSLog(@"Use \"initWithName\" or \"initWithPath\" to create YYCache instance.");
-    return [self initWithPath:nil];
+    return [self initWithPath:@""];
 }
 
 - (instancetype)initWithName:(NSString *)name {

+ 24 - 20
YYCache/YYDiskCache.h

@@ -11,6 +11,8 @@
 
 #import <Foundation/Foundation.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
  YYDiskCache is a thread-safe cache that stores key-value pairs backed by SQLite
  and file system (similar to NSURLCache's disk cache).
@@ -34,7 +36,7 @@
 ///=============================================================================
 
 /** The name of the cache. Default is nil. */
-@property (copy) NSString *name;
+@property (nullable, copy) NSString *name;
 
 /** The path of the cache (read-only). */
 @property (readonly) NSString *path;
@@ -57,7 +59,7 @@
  
  The default value is nil.
  */
-@property (copy) NSData *(^customArchiveBlock)(id object);
+@property (nullable, copy) NSData *(^customArchiveBlock)(id object);
 
 /**
  If this block is not nil, then the block will be used to unarchive object instead
@@ -66,7 +68,7 @@
  
  The default value is nil.
  */
-@property (copy) id (^customUnarchiveBlock)(NSData *data);
+@property (nullable, copy) id (^customUnarchiveBlock)(NSData *data);
 
 /**
  When an object needs to be saved as a file, this block will be invoked to generate
@@ -75,7 +77,7 @@
  
  The default value is nil.
  */
-@property (copy) NSString *(^customFilenameBlock)(NSString *key);
+@property (nullable, copy) NSString *(^customFileNameBlock)(NSString *key);
 
 
 
@@ -91,7 +93,7 @@
  This is not a strict limit — if the cache goes over the limit, some objects in the
  cache could be evicted later in background queue.
  */
-@property (assign) NSUInteger countLimit;
+@property NSUInteger countLimit;
 
 /**
  The maximum total cost that the cache can hold before it starts evicting objects.
@@ -100,7 +102,7 @@
  This is not a strict limit — if the cache goes over the limit, some objects in the
  cache could be evicted later in background queue.
  */
-@property (assign) NSUInteger costLimit;
+@property NSUInteger costLimit;
 
 /**
  The maximum expiry time of objects in cache.
@@ -109,7 +111,7 @@
  This is not a strict limit — if an object goes over the limit, the objects could
  be evicted later in background queue.
  */
-@property (assign) NSTimeInterval ageLimit;
+@property NSTimeInterval ageLimit;
 
 /**
  The minimum free disk space (in bytes) which the cache should kept.
@@ -119,7 +121,7 @@
  to free some disk space. This is not a strict limit—if the free disk space goes
  over the limit, the objects could be evicted later in background queue.
  */
-@property (assign) NSUInteger freeDiskSpaceLimit;
+@property NSUInteger freeDiskSpaceLimit;
 
 /**
  The auto trim check time interval in seconds. Default is 60 (1 minute).
@@ -127,7 +129,7 @@
  @discussion The cache holds an internal timer to check whether the cache reaches
  its limits, and if the limit is reached, it begins to evict objects.
  */
-@property (assign) NSTimeInterval autoTrimInterval;
+@property NSTimeInterval autoTrimInterval;
 
 
 #pragma mark - Initializer
@@ -148,7 +150,7 @@
  @warning If the cache instance for the specified path already exists in memory,
      this method will return it directly, instead of creating a new instance.
  */
-- (instancetype)initWithPath:(NSString *)path;
+- (nullable instancetype)initWithPath:(NSString *)path;
 
 /**
  The designated initializer.
@@ -168,8 +170,8 @@
  @warning If the cache instance for the specified path already exists in memory,
      this method will return it directly, instead of creating a new instance.
  */
-- (instancetype)initWithPath:(NSString *)path
-             inlineThreshold:(NSUInteger)threshold NS_DESIGNATED_INITIALIZER;
+- (nullable instancetype)initWithPath:(NSString *)path
+                      inlineThreshold:(NSUInteger)threshold NS_DESIGNATED_INITIALIZER;
 
 
 #pragma mark - Access Methods
@@ -203,7 +205,7 @@
  @param key A string identifying the value. If nil, just return nil.
  @return The value associated with key, or nil if no value is associated with key.
  */
-- (id<NSCoding>)objectForKey:(NSString *)key;
+- (nullable id<NSCoding>)objectForKey:(NSString *)key;
 
 /**
  Returns the value associated with a given key.
@@ -213,7 +215,7 @@
  @param key A string identifying the value. If nil, just return nil.
  @param block A block which will be invoked in background queue when finished.
  */
-- (void)objectForKey:(NSString *)key withBlock:(void(^)(NSString *key, id<NSCoding> object))block;
+- (void)objectForKey:(NSString *)key withBlock:(void(^)(NSString *key, id<NSCoding> _Nullable object))block;
 
 /**
  Sets the value of the specified key in the cache.
@@ -222,7 +224,7 @@
  @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`.
  @param key    The key with which to associate the value. If nil, this method has no effect.
  */
-- (void)setObject:(id<NSCoding>)object forKey:(NSString *)key;
+- (void)setObject:(nullable id<NSCoding>)object forKey:(NSString *)key;
 
 /**
  Sets the value of the specified key in the cache.
@@ -232,7 +234,7 @@
  @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`.
  @param block  A block which will be invoked in background queue when finished.
  */
-- (void)setObject:(id<NSCoding>)object forKey:(NSString *)key withBlock:(void(^)(void))block;
+- (void)setObject:(nullable id<NSCoding>)object forKey:(NSString *)key withBlock:(void(^)(void))block;
 
 /**
  Removes the value of the specified key in the cache.
@@ -275,8 +277,8 @@
  @param progress This block will be invoked during removing, pass nil to ignore.
  @param end      This block will be invoked at the end, pass nil to ignore.
  */
-- (void)removeAllObjectsWithProgressBlock:(void(^)(int removedCount, int totalCount))progress
-                                 endBlock:(void(^)(BOOL error))end;
+- (void)removeAllObjectsWithProgressBlock:(nullable void(^)(int removedCount, int totalCount))progress
+                                 endBlock:(nullable void(^)(BOOL error))end;
 
 
 /**
@@ -387,7 +389,7 @@
  @param object An object.
  @return The extended data.
  */
-+ (NSData *)getExtendedDataFromObject:(id)object;
++ (nullable NSData *)getExtendedDataFromObject:(id)object;
 
 /**
  Set extended data to an object.
@@ -399,6 +401,8 @@
  @param extendedData The extended data (pass nil to remove).
  @param object       The object.
  */
-+ (void)setExtendedData:(NSData *)extendedData toObject:(id)object;
++ (void)setExtendedData:(nullable NSData *)extendedData toObject:(id)object;
 
 @end
+
+NS_ASSUME_NONNULL_END

+ 2 - 2
YYCache/YYDiskCache.m

@@ -144,7 +144,7 @@ static void _YYDiskCacheSetGlobal(YYDiskCache *cache) {
 
 - (NSString *)_filenameForKey:(NSString *)key {
     NSString *filename = nil;
-    if (_customFilenameBlock) filename = _customFilenameBlock(key);
+    if (_customFileNameBlock) filename = _customFileNameBlock(key);
     if (!filename) filename = _YYNSStringMD5(key);
     return filename;
 }
@@ -153,7 +153,7 @@ static void _YYDiskCacheSetGlobal(YYDiskCache *cache) {
 
 - (instancetype)init {
     @throw [NSException exceptionWithName:@"YYDiskCache init error" reason:@"YYDiskCache must be initialized with a path. Use 'initWithPath:' or 'initWithPath:inlineThreshold:' instead." userInfo:nil];
-    return [self initWithPath:nil inlineThreshold:0];
+    return [self initWithPath:@"" inlineThreshold:0];
 }
 
 - (instancetype)initWithPath:(NSString *)path {

+ 24 - 20
YYCache/YYKVStorage.h

@@ -11,18 +11,20 @@
 
 #import <Foundation/Foundation.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
  YYKVStorageItem is used by `YYKVStorage` to store key-value pair and meta data.
  Typically, you should not use this class directly.
  */
 @interface YYKVStorageItem : NSObject
-@property (nonatomic, strong) NSString *key;        ///< key
-@property (nonatomic, strong) NSData *value;        ///< value
-@property (nonatomic, strong) NSString *filename;   ///< filename (nil if inline)
-@property (nonatomic, assign) int size;             ///< value's size in bytes
-@property (nonatomic, assign) int modTime;          ///< modification unix timestamp
-@property (nonatomic, assign) int accessTime;       ///< last access unix timestamp
-@property (nonatomic, strong) NSData *extendedData; ///< extended data (nil if no extended data)
+@property (nonatomic, strong) NSString *key;                ///< key
+@property (nonatomic, strong) NSData *value;                ///< value
+@property (nullable, nonatomic, strong) NSString *filename; ///< filename (nil if inline)
+@property (nonatomic) int size;                             ///< value's size in bytes
+@property (nonatomic) int modTime;                          ///< modification unix timestamp
+@property (nonatomic) int accessTime;                       ///< last access unix timestamp
+@property (nullable, nonatomic, strong) NSData *extendedData; ///< extended data (nil if no extended data)
 @end
 
 /**
@@ -80,7 +82,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
 
 @property (nonatomic, readonly) NSString *path;        ///< The path of this storage.
 @property (nonatomic, readonly) YYKVStorageType type;  ///< The type of this storage.
-@property (nonatomic, assign) BOOL errorLogsEnabled;   ///< Set `YES` to enable error logs for debug.
+@property (nonatomic) BOOL errorLogsEnabled;           ///< Set `YES` to enable error logs for debug.
 
 #pragma mark - Initializer
 ///=============================================================================
@@ -100,7 +102,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @return  A new storage object, or nil if an error occurs.
  @warning Multiple instances with the same path will make the storage unstable.
  */
-- (instancetype)initWithPath:(NSString *)path type:(YYKVStorageType)type NS_DESIGNATED_INITIALIZER;
+- (nullable instancetype)initWithPath:(NSString *)path type:(YYKVStorageType)type NS_DESIGNATED_INITIALIZER;
 
 
 #pragma mark - Save Items
@@ -155,8 +157,8 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  */
 - (BOOL)saveItemWithKey:(NSString *)key
                   value:(NSData *)value
-               filename:(NSString *)filename
-           extendedData:(NSData *)extendedData;
+               filename:(nullable NSString *)filename
+           extendedData:(nullable NSData *)extendedData;
 
 #pragma mark - Remove Items
 ///=============================================================================
@@ -178,7 +180,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  
  @return Whether succeed.
  */
-- (BOOL)removeItemForKeys:(NSArray *)keys;
+- (BOOL)removeItemForKeys:(NSArray<NSString *> *)keys;
 
 /**
  Remove all items which `value` is larger than a specified size.
@@ -232,8 +234,8 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param progress This block will be invoked during removing, pass nil to ignore.
  @param end      This block will be invoked at the end, pass nil to ignore.
  */
-- (void)removeAllItemsWithProgressBlock:(void(^)(int removedCount, int totalCount))progress
-                               endBlock:(void(^)(BOOL error))end;
+- (void)removeAllItemsWithProgressBlock:(nullable void(^)(int removedCount, int totalCount))progress
+                               endBlock:(nullable void(^)(BOOL error))end;
 
 
 #pragma mark - Get Items
@@ -247,7 +249,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param key A specified key.
  @return Item for the key, or nil if not exists / error occurs.
  */
-- (YYKVStorageItem *)getItemForKey:(NSString *)key;
+- (nullable YYKVStorageItem *)getItemForKey:(NSString *)key;
 
 /**
  Get item information with a specified key.
@@ -256,7 +258,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param key A specified key.
  @return Item information for the key, or nil if not exists / error occurs.
  */
-- (YYKVStorageItem *)getItemInfoForKey:(NSString *)key;
+- (nullable YYKVStorageItem *)getItemInfoForKey:(NSString *)key;
 
 /**
  Get item value with a specified key.
@@ -264,7 +266,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param key  A specified key.
  @return Item's value, or nil if not exists / error occurs.
  */
-- (NSData *)getItemValueForKey:(NSString *)key;
+- (nullable NSData *)getItemValueForKey:(NSString *)key;
 
 /**
  Get items with an array of keys.
@@ -272,7 +274,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param keys  An array of specified keys.
  @return An array of `YYKVStorageItem`, or nil if not exists / error occurs.
  */
-- (NSArray *)getItemForKeys:(NSArray *)keys;
+- (nullable NSArray<YYKVStorageItem *> *)getItemForKeys:(NSArray<NSString *> *)keys;
 
 /**
  Get item infomartions with an array of keys.
@@ -281,7 +283,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @param keys  An array of specified keys.
  @return An array of `YYKVStorageItem`, or nil if not exists / error occurs.
  */
-- (NSArray *)getItemInfoForKeys:(NSArray *)keys;
+- (nullable NSArray<YYKVStorageItem *> *)getItemInfoForKeys:(NSArray<NSString *> *)keys;
 
 /**
  Get items value with an array of keys.
@@ -290,7 +292,7 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
  @return A dictionary which key is 'key' and value is 'value', or nil if not 
     exists / error occurs.
  */
-- (NSDictionary *)getItemValueForKeys:(NSArray *)keys;
+- (nullable NSDictionary<NSString *, NSData *> *)getItemValueForKeys:(NSArray<NSString *> *)keys;
 
 #pragma mark - Get Storage Status
 ///=============================================================================
@@ -319,3 +321,5 @@ typedef NS_ENUM(NSUInteger, YYKVStorageType) {
 - (int)getItemsSize;
 
 @end
+
+NS_ASSUME_NONNULL_END

+ 1 - 1
YYCache/YYKVStorage.m

@@ -649,7 +649,7 @@ static NSString *const kTrashDirectoryName = @"trash";
 
 - (instancetype)init {
     @throw [NSException exceptionWithName:@"YYKVStorage init error" reason:@"Please use the designated initializer and pass the 'path' and 'type'." userInfo:nil];
-    return [self initWithPath:nil type:YYKVStorageTypeFile];
+    return [self initWithPath:@"" type:YYKVStorageTypeFile];
 }
 
 - (instancetype)initWithPath:(NSString *)path type:(YYKVStorageType)type {

+ 18 - 14
YYCache/YYMemoryCache.h

@@ -11,6 +11,8 @@
 
 #import <Foundation/Foundation.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
  YYMemoryCache is a fast in-memory cache that stores key-value pairs.
  In contrast to NSDictionary, keys are retained and not copied.
@@ -34,7 +36,7 @@
 ///=============================================================================
 
 /** The name of the cache. Default is nil. */
-@property (copy) NSString *name;
+@property (nullable, copy) NSString *name;
 
 /** The number of objects in the cache (read-only) */
 @property (readonly) NSUInteger totalCount;
@@ -55,7 +57,7 @@
  This is not a strict limit—if the cache goes over the limit, some objects in the
  cache could be evicted later in backgound thread.
  */
-@property (assign) NSUInteger countLimit;
+@property NSUInteger countLimit;
 
 /**
  The maximum total cost that the cache can hold before it starts evicting objects.
@@ -64,7 +66,7 @@
  This is not a strict limit—if the cache goes over the limit, some objects in the
  cache could be evicted later in backgound thread.
  */
-@property (assign) NSUInteger costLimit;
+@property NSUInteger costLimit;
 
 /**
  The maximum expiry time of objects in cache.
@@ -73,7 +75,7 @@
  This is not a strict limit—if an object goes over the limit, the object could 
  be evicted later in backgound thread.
  */
-@property (assign) NSTimeInterval ageLimit;
+@property NSTimeInterval ageLimit;
 
 /**
  The auto trim check time interval in seconds. Default is 5.0.
@@ -81,31 +83,31 @@
  @discussion The cache holds an internal timer to check whether the cache reaches 
  its limits, and if the limit is reached, it begins to evict objects.
  */
-@property (assign) NSTimeInterval autoTrimInterval;
+@property NSTimeInterval autoTrimInterval;
 
 /**
  If `YES`, the cache will remove all objects when the app receives a memory warning.
  The default value is `YES`.
  */
-@property (assign) BOOL shouldRemoveAllObjectsOnMemoryWarning;
+@property BOOL shouldRemoveAllObjectsOnMemoryWarning;
 
 /**
  If `YES`, The cache will remove all objects when the app enter background.
  The default value is `YES`.
  */
-@property (assign) BOOL shouldRemoveAllObjectsWhenEnteringBackground;
+@property BOOL shouldRemoveAllObjectsWhenEnteringBackground;
 
 /**
  A block to be executed when the app receives a memory warning.
  The default value is nil.
  */
-@property (copy) void(^didReceiveMemoryWarningBlock)(YYMemoryCache *cache);
+@property (nullable, copy) void(^didReceiveMemoryWarningBlock)(YYMemoryCache *cache);
 
 /**
  A block to be executed when the app enter background.
  The default value is nil.
  */
-@property (copy) void(^didEnterBackgroundBlock)(YYMemoryCache *cache);
+@property (nullable, copy) void(^didEnterBackgroundBlock)(YYMemoryCache *cache);
 
 /**
  If `YES`, the key-value pair will be released on main thread, otherwise on
@@ -114,14 +116,14 @@
  @discussion You may set this value to `YES` if the key-value object contains
  the instance which should be released in main thread (such as UIView/CALayer).
  */
-@property (assign) BOOL releaseOnMainThread;
+@property BOOL releaseOnMainThread;
 
 /**
  If `YES`, the key-value pair will be released asynchronously to avoid blocking 
  the access methods, otherwise it will be released in the access method  
  (such as removeObjectForKey:). Default is YES.
  */
-@property (assign) BOOL releaseAsynchronously;
+@property BOOL releaseAsynchronously;
 
 
 #pragma mark - Access Methods
@@ -143,7 +145,7 @@
  @param key An object identifying the value. If nil, just return nil.
  @return The value associated with key, or nil if no value is associated with key.
  */
-- (id)objectForKey:(id)key;
+- (nullable id)objectForKey:(id)key;
 
 /**
  Sets the value of the specified key in the cache (0 cost).
@@ -153,7 +155,7 @@
  @discussion Unlike an NSMutableDictionary object, a cache does not copy the key 
  objects that are put into it.
  */
-- (void)setObject:(id)object forKey:(id)key;
+- (void)setObject:(nullable id)object forKey:(id)key;
 
 /**
  Sets the value of the specified key in the cache, and associates the key-value 
@@ -165,7 +167,7 @@
  @discussion Unlike an NSMutableDictionary object, a cache does not copy the key
  objects that are put into it.
  */
-- (void)setObject:(id)object forKey:(id)key withCost:(NSUInteger)cost;
+- (void)setObject:(nullable id)object forKey:(id)key withCost:(NSUInteger)cost;
 
 /**
  Removes the value of the specified key in the cache.
@@ -207,3 +209,5 @@
 - (void)trimToAge:(NSTimeInterval)age;
 
 @end
+
+NS_ASSUME_NONNULL_END