Permalink
Browse files

NS_ENUM & NS_OPTIONS

  • Loading branch information...
1 parent 6dc02bd commit 6d8133557c5eb63017420e5b04678e788d8e1d3c @akhenakh akhenakh committed Jan 7, 2014
View
5 SDWebImage/SDImageCache.h
@@ -9,11 +9,11 @@
#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
-enum SDImageCacheType {
+typedef NS_ENUM(NSInteger, SDImageCacheType) {
/**
* The image wasn't available the SDWebImage caches, but was downloaded from the web.
*/
- SDImageCacheTypeNone = 0,
+ SDImageCacheTypeNone,
/**
* The image was obtained from the disk cache.
*/
@@ -23,7 +23,6 @@ enum SDImageCacheType {
*/
SDImageCacheTypeMemory
};
-typedef enum SDImageCacheType SDImageCacheType;
/**
* SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed
View
8 SDWebImage/SDWebImageCompat.h
@@ -31,6 +31,14 @@
#endif
+#ifndef NS_ENUM
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#endif
+
+#ifndef NS_OPTIONS
+#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+#endif
+
#if OS_OBJECT_USE_OBJC
#undef SDDispatchQueueRelease
#undef SDDispatchQueueSetterSementics
View
8 SDWebImage/SDWebImageDownloader.h
@@ -10,7 +10,7 @@
#import "SDWebImageCompat.h"
#import "SDWebImageOperation.h"
-typedef enum {
+typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
SDWebImageDownloaderLowPriority = 1 << 0,
SDWebImageDownloaderProgressiveDownload = 1 << 1,
/**
@@ -39,9 +39,9 @@ typedef enum {
*/
SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6
-} SDWebImageDownloaderOptions;
+};
-typedef enum {
+typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
SDWebImageDownloaderFIFOExecutionOrder,
/**
* Default value. All download operations will execute in queue style (first-in-first-out).
@@ -50,7 +50,7 @@ typedef enum {
/**
* All download operations will execute in stack style (last-in-first-out).
*/
-} SDWebImageDownloaderExecutionOrder;
+};
extern NSString *const SDWebImageDownloadStartNotification;
extern NSString *const SDWebImageDownloadStopNotification;
View
4 SDWebImage/SDWebImageManager.h
@@ -11,7 +11,7 @@
#import "SDWebImageDownloader.h"
#import "SDImageCache.h"
-typedef enum {
+typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
/**
* By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
* This flag disable this blacklisting.
@@ -56,7 +56,7 @@ typedef enum {
* Useful for testing purposes. Use with caution in production.
*/
SDWebImageAllowInvalidSSLCertificates = 1 << 7
-} SDWebImageOptions;
+};
typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType);

0 comments on commit 6d81335

Please sign in to comment.