Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ochs committed Feb 24, 2016
2 parents 0b50b97 + ca6b2da commit 815572c
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 51 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The versioning in this project is based on [Semantic Versioning](http://semver.org).

## v0.4.0
The `localizedDescription` of an `NSError` will now be used as the alert's title by default. This is a **breaking change** from the previous versions. Make sure to use the `NSLocalizedDescriptionKey` in your custom errors instead of the `NSLocalizedFailureReasonErrorKey`. This change was made to be consistent with the OS X error presentation.
## v0.3.0
Errors will now be queued to prevent several error messages from popping up at the same time. Also multiple error messages of the same type are coalesced and only displayed once.
## v0.2.0
Expand Down
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The project is available under the Apache 2 license. Please see the LICENSE file


## Contributors
### v0.4.0
- Alex Hoppen - [Fixed issue when importing into Swift CocoaPod](https://github.com/Hotel-Reservation-Service/HRSCustomErrorHandling/pull/10)
### v0.3.0
- Roland Lindner - [Fix compiler error on uncasted objc_msgSend calls in Xcode 6.2](https://github.com/Hotel-Reservation-Service/HRSCustomErrorHandling/pull/6)

Expand Down
2 changes: 1 addition & 1 deletion Example/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'cocoapods', '~> 0.36'
gem 'cocoapods', '~> 0.39'
64 changes: 35 additions & 29 deletions Example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.0)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (0.8.1)
cocoapods (0.36.0)
activesupport (>= 3.2.15)
claide (~> 0.8.1)
cocoapods-core (= 0.36.0)
cocoapods-downloader (~> 0.8.1)
cocoapods-plugins (~> 0.4.1)
cocoapods-trunk (~> 0.6.0)
cocoapods-try (~> 0.4.3)
claide (0.9.1)
cocoapods (0.39.0)
activesupport (>= 4.0.2)
claide (~> 0.9.1)
cocoapods-core (= 0.39.0)
cocoapods-downloader (~> 0.9.3)
cocoapods-plugins (~> 0.4.2)
cocoapods-search (~> 0.1.0)
cocoapods-stats (~> 0.6.2)
cocoapods-trunk (~> 0.6.4)
cocoapods-try (~> 0.5.1)
colored (~> 1.2)
escape (~> 0.0.4)
molinillo (~> 0.2.1)
nap (~> 0.8)
open4 (~> 1.3)
xcodeproj (~> 0.23.0)
cocoapods-core (0.36.0)
activesupport (>= 3.2.15)
molinillo (~> 0.4.0)
nap (~> 1.0)
xcodeproj (~> 0.28.2)
cocoapods-core (0.39.0)
activesupport (>= 4.0.2)
fuzzy_match (~> 2.0.4)
nap (~> 0.8.0)
cocoapods-downloader (0.8.1)
cocoapods-plugins (0.4.1)
nap (~> 1.0)
cocoapods-downloader (0.9.3)
cocoapods-plugins (0.4.2)
nap
cocoapods-trunk (0.6.0)
nap (>= 0.8)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2)
cocoapods-trunk (0.6.4)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
cocoapods-try (0.4.3)
cocoapods-try (0.5.1)
colored (1.2)
escape (0.0.4)
fuzzy_match (2.0.4)
i18n (0.7.0)
json (1.8.2)
minitest (5.5.1)
molinillo (0.2.1)
nap (0.8.0)
json (1.8.3)
minitest (5.7.0)
molinillo (0.4.0)
nap (1.0.0)
netrc (0.7.8)
open4 (1.3.4)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
xcodeproj (0.23.0)
xcodeproj (0.28.2)
activesupport (>= 3)
claide (~> 0.9.1)
colored (~> 1.2)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 0.36)
cocoapods (~> 0.39)

BUNDLED WITH
1.10.6
32 changes: 32 additions & 0 deletions Example/HRSCustomErrorHandling.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
6003F587195388D20070C39A /* Frameworks */,
6003F588195388D20070C39A /* Resources */,
94A8A00043D8422B9972DEF3 /* Copy Pods Resources */,
922CF90FE1D5D7F0B6DC8C60 /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -232,6 +233,7 @@
6003F5AB195388D20070C39A /* Frameworks */,
6003F5AC195388D20070C39A /* Resources */,
6B10C81F541B401ABBE6B17F /* Copy Pods Resources */,
8295081662B0F5488C733E06 /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -328,6 +330,36 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
8295081662B0F5488C733E06 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
922CF90FE1D5D7F0B6DC8C60 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HRSCustomErrorHandling/Pods-HRSCustomErrorHandling-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
94A8A00043D8422B9972DEF3 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- HRSCustomErrorHandling (0.3.0)
- OCMock (3.1.2)
- HRSCustomErrorHandling (0.4.0)
- OCMock (3.2.2)

DEPENDENCIES:
- HRSCustomErrorHandling (from `../`)
Expand All @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
HRSCustomErrorHandling: 15b590e4da855b718c9f1042defe9c2b54f919d4
OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92
HRSCustomErrorHandling: 93fa0474c3d71c501f34ff0d4a1a4424ca09929b
OCMock: 18c9b7e67d4c2770e95bb77a9cc1ae0c91fe3835

COCOAPODS: 0.36.0
COCOAPODS: 0.39.0
2 changes: 1 addition & 1 deletion HRSCustomErrorHandling.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "HRSCustomErrorHandling"
s.version = "0.3.0"
s.version = "0.4.0"
s.summary = "HRSCustomErrorHandling provides an easy way to handle error presentation and creation on iOS."
s.description = <<-DESC
HRSCustomErrorHandling is a small Framework that provides a base implementation for error handling in iOS applications. It deals with the problem to streamline the presentation of errors in various parts of an application as well as provide APIs to implement error specific recovery options the user of the application can choose from.
Expand Down
8 changes: 4 additions & 4 deletions Pod/Classes/HRSCustomErrorHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// limitations under the License.
//

#import <HRSCustomErrorHandling/UIResponder+HRSCustomErrorPresentation.h>
#import <HRSCustomErrorHandling/HRSErrorCoalescingQueue.h>
#import <HRSCustomErrorHandling/HRSErrorPresenter.h>
#import <HRSCustomErrorHandling/HRSErrorRecoveryAttempter.h>
#import "UIResponder+HRSCustomErrorPresentation.h"
#import "HRSErrorCoalescingQueue.h"
#import "HRSErrorPresenter.h"
#import "HRSErrorRecoveryAttempter.h"
21 changes: 19 additions & 2 deletions Pod/Classes/HRSErrorPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#import "HRSErrorPresenter.h"

#import <objc/runtime.h>

#import "HRSErrorLocalizationHelper.h"
#import "HRSErrorPresenterDelegate.h"
#import "HRSErrorRecoveryAttempter.h"


@interface HRSErrorPresenter ()
Expand All @@ -38,9 +41,23 @@ - (instancetype)initWithError:(NSError *)error completionHandler:(void (^)(BOOL)
{
HRSErrorPresenterDelegate *delegate = [HRSErrorPresenterDelegate delegateWithError:error completionHandler:completionHandler];

self = [super initWithTitle:[error localizedFailureReason] message:[error localizedRecoverySuggestion] delegate:delegate cancelButtonTitle:nil otherButtonTitles:nil];
self = [super initWithTitle:error.localizedDescription message:error.localizedRecoverySuggestion delegate:delegate cancelButtonTitle:nil otherButtonTitles:nil];

for (NSString *title in [[error localizedRecoveryOptions] reverseObjectEnumerator]) {
NSArray *recoveryOptions = error.localizedRecoveryOptions;
if (recoveryOptions.count == 0) { // the error does not have recovery options... try to be intelligent...
id recoveryAttempter = error.recoveryAttempter;
if (recoveryAttempter && [recoveryAttempter isKindOfClass:[HRSErrorRecoveryAttempter class]]) {
// the recovery attempter belongs to the HRSCustomErrorHandling
// framework. Let's use its recovery options!
recoveryOptions = ((HRSErrorRecoveryAttempter *)recoveryAttempter).localizedRecoveryOptions;
}
}
if (recoveryOptions.count == 0) {
// Still no recovery options found. Fall back to a default ok localization
recoveryOptions = @[ [HRSErrorLocalizationHelper okLocalization] ];
}

for (NSString *title in [recoveryOptions reverseObjectEnumerator]) {
[self addButtonWithTitle:title];
}

Expand Down
12 changes: 4 additions & 8 deletions Pod/Classes/HRSErrorRecoveryAttempter.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import <objc/message.h>

#import "HRSErrorLocalizationHelper.h"


@interface HRSErrorRecoveryAttempter ()

Expand Down Expand Up @@ -53,23 +55,17 @@ - (void)addRecoveryOptionWithTitle:(NSString *)title recoveryAttempt:(BOOL(^)())

#pragma mark - Convenience options

- (NSString *)_localizedTitleFromKey:(NSString *)key
{
NSBundle *uiKitBundle = [NSBundle bundleForClass:[UIResponder class]];
return [uiKitBundle localizedStringForKey:key value:key table:nil];
}

- (void)addOkayRecoveryOption
{
NSString *title = [self _localizedTitleFromKey:@"OK"];
NSString *title = [HRSErrorLocalizationHelper okLocalization];
[self addRecoveryOptionWithTitle:title recoveryAttempt:^BOOL{
return NO;
}];
}

- (void)addCancelRecoveryOption
{
NSString *title = [self _localizedTitleFromKey:@"Cancel"];
NSString *title = [HRSErrorLocalizationHelper cancelLocalization];
[self addRecoveryOptionWithTitle:title recoveryAttempt:^BOOL{
return NO;
}];
Expand Down
8 changes: 8 additions & 0 deletions Pod/Classes/Private/HRSErrorLocalizationHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>

@interface HRSErrorLocalizationHelper : NSObject

+ (NSString *)okLocalization;
+ (NSString *)cancelLocalization;

@end
24 changes: 24 additions & 0 deletions Pod/Classes/Private/HRSErrorLocalizationHelper.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#import "HRSErrorLocalizationHelper.h"

@implementation HRSErrorLocalizationHelper

+ (NSString *)localizedTitleFromKey:(NSString *)key
{
NSBundle *uiKitBundle = [NSBundle bundleForClass:[UIResponder class]];
return [uiKitBundle localizedStringForKey:key value:key table:nil];
}

+ (NSString *)okLocalization
{
NSString *title = [self localizedTitleFromKey:@"OK"];
return title;
}

+ (NSString *)cancelLocalization
{
NSString *title = [self localizedTitleFromKey:@"Cancel"];
return title;
}


@end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.0

0 comments on commit 815572c

Please sign in to comment.