Skip to content

Commit 6d81335

Browse files
committed
NS_ENUM & NS_OPTIONS
1 parent 6dc02bd commit 6d81335

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

SDWebImage/SDImageCache.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#import <Foundation/Foundation.h>
1010
#import "SDWebImageCompat.h"
1111

12-
enum SDImageCacheType {
12+
typedef NS_ENUM(NSInteger, SDImageCacheType) {
1313
/**
1414
* The image wasn't available the SDWebImage caches, but was downloaded from the web.
1515
*/
16-
SDImageCacheTypeNone = 0,
16+
SDImageCacheTypeNone,
1717
/**
1818
* The image was obtained from the disk cache.
1919
*/
@@ -23,7 +23,6 @@ enum SDImageCacheType {
2323
*/
2424
SDImageCacheTypeMemory
2525
};
26-
typedef enum SDImageCacheType SDImageCacheType;
2726

2827
/**
2928
* SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed

SDWebImage/SDWebImageCompat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131

3232
#endif
3333

34+
#ifndef NS_ENUM
35+
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
36+
#endif
37+
38+
#ifndef NS_OPTIONS
39+
#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
40+
#endif
41+
3442
#if OS_OBJECT_USE_OBJC
3543
#undef SDDispatchQueueRelease
3644
#undef SDDispatchQueueSetterSementics

SDWebImage/SDWebImageDownloader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "SDWebImageCompat.h"
1111
#import "SDWebImageOperation.h"
1212

13-
typedef enum {
13+
typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
1414
SDWebImageDownloaderLowPriority = 1 << 0,
1515
SDWebImageDownloaderProgressiveDownload = 1 << 1,
1616
/**
@@ -39,9 +39,9 @@ typedef enum {
3939
*/
4040
SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6
4141

42-
} SDWebImageDownloaderOptions;
42+
};
4343

44-
typedef enum {
44+
typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
4545
SDWebImageDownloaderFIFOExecutionOrder,
4646
/**
4747
* Default value. All download operations will execute in queue style (first-in-first-out).
@@ -50,7 +50,7 @@ typedef enum {
5050
/**
5151
* All download operations will execute in stack style (last-in-first-out).
5252
*/
53-
} SDWebImageDownloaderExecutionOrder;
53+
};
5454

5555
extern NSString *const SDWebImageDownloadStartNotification;
5656
extern NSString *const SDWebImageDownloadStopNotification;

SDWebImage/SDWebImageManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import "SDWebImageDownloader.h"
1212
#import "SDImageCache.h"
1313

14-
typedef enum {
14+
typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
1515
/**
1616
* By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
1717
* This flag disable this blacklisting.
@@ -56,7 +56,7 @@ typedef enum {
5656
* Useful for testing purposes. Use with caution in production.
5757
*/
5858
SDWebImageAllowInvalidSSLCertificates = 1 << 7
59-
} SDWebImageOptions;
59+
};
6060

6161
typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType);
6262

0 commit comments

Comments
 (0)