commit | author | age
|
6e1425
|
1 |
// UIAlertView+AFNetworking.h |
H |
2 |
// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) |
|
3 |
// |
|
4 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
5 |
// of this software and associated documentation files (the "Software"), to deal |
|
6 |
// in the Software without restriction, including without limitation the rights |
|
7 |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
8 |
// copies of the Software, and to permit persons to whom the Software is |
|
9 |
// furnished to do so, subject to the following conditions: |
|
10 |
// |
|
11 |
// The above copyright notice and this permission notice shall be included in |
|
12 |
// all copies or substantial portions of the Software. |
|
13 |
// |
|
14 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
15 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
16 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
17 |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
18 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
19 |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
20 |
// THE SOFTWARE. |
|
21 |
|
|
22 |
#import <Foundation/Foundation.h> |
|
23 |
|
|
24 |
#import <Availability.h> |
|
25 |
|
|
26 |
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) |
|
27 |
|
|
28 |
#import <UIKit/UIKit.h> |
|
29 |
|
|
30 |
NS_ASSUME_NONNULL_BEGIN |
|
31 |
|
|
32 |
@class AFURLConnectionOperation; |
|
33 |
|
|
34 |
/** |
|
35 |
This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. |
|
36 |
*/ |
|
37 |
@interface UIAlertView (AFNetworking) |
|
38 |
|
|
39 |
///------------------------------------- |
|
40 |
/// @name Showing Alert for Session Task |
|
41 |
///------------------------------------- |
|
42 |
|
|
43 |
/** |
|
44 |
Shows an alert view with the error of the specified session task, if any. |
|
45 |
|
|
46 |
@param task The session task. |
|
47 |
@param delegate The alert view delegate. |
|
48 |
*/ |
|
49 |
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 |
|
50 |
+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task |
|
51 |
delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); |
|
52 |
#endif |
|
53 |
|
|
54 |
/** |
|
55 |
Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. |
|
56 |
|
|
57 |
@param task The session task. |
|
58 |
@param delegate The alert view delegate. |
|
59 |
@param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. |
|
60 |
@param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. |
|
61 |
*/ |
|
62 |
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 |
|
63 |
+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task |
|
64 |
delegate:(nullable id)delegate |
|
65 |
cancelButtonTitle:(nullable NSString *)cancelButtonTitle |
|
66 |
otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); |
|
67 |
#endif |
|
68 |
|
|
69 |
///------------------------------------------ |
|
70 |
/// @name Showing Alert for Request Operation |
|
71 |
///------------------------------------------ |
|
72 |
|
|
73 |
/** |
|
74 |
Shows an alert view with the error of the specified request operation, if any. |
|
75 |
|
|
76 |
@param operation The request operation. |
|
77 |
@param delegate The alert view delegate. |
|
78 |
*/ |
|
79 |
+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation |
|
80 |
delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); |
|
81 |
|
|
82 |
/** |
|
83 |
Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. |
|
84 |
|
|
85 |
@param operation The request operation. |
|
86 |
@param delegate The alert view delegate. |
|
87 |
@param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. |
|
88 |
@param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. |
|
89 |
*/ |
|
90 |
+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation |
|
91 |
delegate:(nullable id)delegate |
|
92 |
cancelButtonTitle:(nullable NSString *)cancelButtonTitle |
|
93 |
otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); |
|
94 |
|
|
95 |
@end |
|
96 |
|
|
97 |
NS_ASSUME_NONNULL_END |
|
98 |
|
|
99 |
#endif |