-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorAlert.m
47 lines (37 loc) · 1.63 KB
/
ErrorAlert.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// ErrorAlert.m
//
// Created by Mark Bridges on 26/11/2012.
// Copyright (c) 2012 Mark Bridges. All rights reserved.
//
//
// You are hereby granted to use this however you want.
// This software is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
#import "ErrorAlert.h"
@implementation ErrorAlert
+(void)showError:(NSError *)error{
[self performSelectorOnMainThread:@selector(showErrorOnMainThread:) withObject:error waitUntilDone:FALSE];
}
+(void)showErrorOnMainThread:(NSError*)error{
NSString *message = [NSString stringWithFormat:@"Description: %@",error.localizedDescription];
if (error.localizedFailureReason) {
message = [NSString stringWithFormat:@"%@\nReason: %@", message, error.localizedDescription];
}
if (error.localizedRecoverySuggestion) {
message = [NSString stringWithFormat:@"%@\nRecovery Suggestion: %@", message, error.localizedRecoverySuggestion];
}
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"A Glitch Has Occured" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[errorAlert show];
NSLog(@"Error %@",message);
}
+(void)showErrorString:(NSString*)error{
[self performSelectorOnMainThread:@selector(showErrorStringOnMainThread:) withObject:error waitUntilDone:FALSE];
}
+(void)showErrorStringOnMainThread:(NSString*)error{
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"Error Occured" message:error delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[errorAlert show];
NSLog(@"Error %@",error);
}
@end