Skip to content

Commit

Permalink
[Breaking Swift API] Use Fancy NSError Macros (#440)
Browse files Browse the repository at this point in the history
* Use fancy NS_ERROR_ENUM macros

* Update changelog

* Use the typedef variant
  • Loading branch information
Adlai-Holler authored Mar 13, 2018
1 parent 8e33b6d commit db8d332
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [new] Add support for higher frame rate devices to animated images. [#417](https://github.com/pinterest/PINRemoteImage/pull/417) [garrettmoon](https://github.com/garrettmoon)
- [fixed] Fixes non-animated GIFs being delivered as an animated image. [#434](https://github.com/pinterest/PINRemoteImage/pull/434) [garrettmoon](https://github.com/garrettmoon)
- Remove unused code that supported iOS < 7. [#435](https://github.com/pinterest/PINRemoteImage/pull/435) [Adlai-Holler](https://github.com/Adlai-Holler)
- Use NS_ERROR_ENUM to improve Swift import. [#440](https://github.com/pinterest/PINRemoteImage/pull/440) [Adlai-Holler](https://github.com/Adlai-Holler)

## 3.0.0 Beta 13
- [new] Support for webp and improved support for GIFs. [#411](https://github.com/pinterest/PINRemoteImage/pull/411) [garrettmoon](https://github.com/garrettmoon)
Expand Down
8 changes: 6 additions & 2 deletions Source/Classes/AnimatedImages/PINAnimatedImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

#import "PINRemoteImageMacros.h"

extern NSString * _Nonnull kPINAnimatedImageErrorDomain;
NS_ASSUME_NONNULL_BEGIN

extern NSErrorDomain const kPINAnimatedImageErrorDomain;

/**
PINAnimatedImage decoding and processing errors.
*/
typedef NS_ENUM(NSUInteger, PINAnimatedImageError) {
typedef NS_ERROR_ENUM(kPINAnimatedImageErrorDomain, PINAnimatedImageErrorCode) {
/** No error, yay! */
PINAnimatedImageErrorNoError = 0,
/** Could not create a necessary file. */
Expand Down Expand Up @@ -155,3 +157,5 @@ typedef void(^PINAnimatedImageInfoReady)(PINImage * _Nonnull coverImage);
- (CFTimeInterval)durationAtIndex:(NSUInteger)index;

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion Source/Classes/AnimatedImages/PINAnimatedImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "PINAnimatedImage.h"

NSString *kPINAnimatedImageErrorDomain = @"kPINAnimatedImageErrorDomain";
NSErrorDomain const kPINAnimatedImageErrorDomain = @"kPINAnimatedImageErrorDomain";

//http://nullsleep.tumblr.com/post/16524517190/animated-gif-minimum-frame-delay-browser
const Float32 kPINAnimatedImageDefaultDuration = 0.1;
Expand Down
4 changes: 2 additions & 2 deletions Source/Classes/PINRemoteImageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

@class PINRemoteImageManagerResult;

extern NSString * __nonnull const PINRemoteImageManagerErrorDomain;
extern NSErrorDomain _Nonnull const PINRemoteImageManagerErrorDomain;

/**
Error codes returned by PINRemoteImage
*/
typedef NS_ENUM(NSUInteger, PINRemoteImageManagerError) {
typedef NS_ERROR_ENUM(PINRemoteImageManagerErrorDomain, PINRemoteImageManagerError) {
/** The image failed to decode */
PINRemoteImageManagerErrorFailedToDecodeImage = 1,
/** The image could not be downloaded and therefore could not be processed */
Expand Down
2 changes: 1 addition & 1 deletion Source/Classes/PINRemoteImageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ float dataTaskPriorityWithImageManagerPriority(PINRemoteImageManagerPriority pri
}
}

NSString * const PINRemoteImageManagerErrorDomain = @"PINRemoteImageManagerErrorDomain";
NSErrorDomain const PINRemoteImageManagerErrorDomain = @"PINRemoteImageManagerErrorDomain";
NSString * const PINRemoteImageCacheKey = @"cacheKey";
NSString * const PINRemoteImageCacheKeyResumePrefix = @"R-";
typedef void (^PINRemoteImageManagerDataCompletion)(NSData *data, NSURLResponse *response, NSError *error);
Expand Down
2 changes: 1 addition & 1 deletion Source/Classes/PINURLSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>

extern NSString * __nonnull const PINURLErrorDomain;
extern NSErrorDomain _Nonnull const PINURLErrorDomain;

@protocol PINURLSessionManagerDelegate <NSObject>

Expand Down
2 changes: 1 addition & 1 deletion Source/Classes/PINURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#import "PINSpeedRecorder.h"

NSString * const PINURLErrorDomain = @"PINURLErrorDomain";
NSErrorDomain const PINURLErrorDomain = @"PINURLErrorDomain";

@interface PINURLSessionManager () <NSURLSessionDelegate, NSURLSessionDataDelegate>

Expand Down

0 comments on commit db8d332

Please sign in to comment.