[Issue #489] Adding userInfo dictionary with current status in reachability changes

This commit is contained in:
Mattt Thompson 2012-08-31 09:04:54 -07:00
parent 1a23b98778
commit ec0240f6e4
2 changed files with 14 additions and 5 deletions

View file

@ -444,6 +444,14 @@ typedef enum {
`AFNetworkReachabilityStatusReachableViaWiFi` `AFNetworkReachabilityStatusReachableViaWiFi`
The `baseURL` host can be reached via a Wi-Fi connection. The `baseURL` host can be reached via a Wi-Fi connection.
### Keys for Notification UserInfo Dictionary
Strings that are used as keys in a userinfo dictionary in a network reachability status change notification.
`AFNetworkingReachabilityNotificationStatusItem`
A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
### Parameter Encoding ### Parameter Encoding
The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values. The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
@ -488,13 +496,13 @@ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *paramete
/** /**
Posted when network reachability changes. Posted when network reachability changes.
The notification object is an `NSNumber` object containing the boolean value for the current network reachability. This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
This notification contains no information in the `userInfo` dictionary.
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (Prefix.pch). @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (Prefix.pch).
*/ */
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
extern NSString * const AFNetworkingReachabilityDidChangeNotification; extern NSString * const AFNetworkingReachabilityDidChangeNotification;
extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
#endif #endif
#pragma mark - #pragma mark -

View file

@ -41,8 +41,6 @@
#import <netdb.h> #import <netdb.h>
#endif #endif
NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
@interface AFMultipartFormData : NSObject <AFMultipartFormData> @interface AFMultipartFormData : NSObject <AFMultipartFormData>
- (id)initWithURLRequest:(NSMutableURLRequest *)request - (id)initWithURLRequest:(NSMutableURLRequest *)request
@ -55,6 +53,9 @@ NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire
#pragma mark - #pragma mark -
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
typedef SCNetworkReachabilityRef AFNetworkReachabilityRef; typedef SCNetworkReachabilityRef AFNetworkReachabilityRef;
typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
#else #else
@ -332,7 +333,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ
block(status); block(status);
} }
[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:[NSNumber numberWithInt:status]]; [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]];
} }
static const void * AFNetworkReachabilityRetainCallback(const void *info) { static const void * AFNetworkReachabilityRetainCallback(const void *info) {