AFJSONResponseSerializer Class Reference

AFJSONResponseSerializer Class Reference

Inherits from AFHTTPResponseSerializer : NSObject
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFJSONResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes JSON responses.

By default, AFJSONResponseSerializer accepts the following MIME types, which includes the official standard, application/json, as well as other commonly-used types:

  • application/json
  • text/json
  • text/javascript

Other Methods

  readingOptions

Options for reading the response JSON data and creating the Foundation objects. For possible values, see the NSJSONSerialization documentation section “NSJSONReadingOptions”. 0 by default.

@property (nonatomic, assign) NSJSONReadingOptions readingOptions

Declared In

AFURLResponseSerialization.h

  removesKeysWithNullValues

Whether to remove keys with NSNull values from response JSON. Defaults to NO.

@property (nonatomic, assign) BOOL removesKeysWithNullValues

Declared In

AFURLResponseSerialization.h

+ serializerWithReadingOptions:

Creates and returns a JSON serializer with specified reading and writing options.

+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions

Parameters

readingOptions

The specified JSON reading options.

Declared In

AFURLResponseSerialization.h

Other Methods

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLResponseSerialization.h

AFJSONRequestSerializer Class Reference

AFJSONRequestSerializer Class Reference

Inherits from AFHTTPRequestSerializer : NSObject
Declared in AFURLRequestSerialization.h
AFURLRequestSerialization.m

Overview

AFJSONRequestSerializer is a subclass of AFHTTPRequestSerializer that encodes parameters as JSON using NSJSONSerialization, setting the Content-Type of the encoded request to application/json.

Other Methods

  writingOptions

Options for writing the request JSON data from Foundation objects. For possible values, see the NSJSONSerialization documentation section “NSJSONWritingOptions”. 0 by default.

@property (nonatomic, assign) NSJSONWritingOptions writingOptions

Declared In

AFURLRequestSerialization.h

+ serializerWithWritingOptions:

Creates and returns a JSON serializer with specified reading and writing options.

+ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions

Parameters

writingOptions

The specified JSON writing options.

Declared In

AFURLRequestSerialization.h

Other Methods

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLRequestSerialization.h

AFNetworkActivityIndicatorManager Class Reference

AFNetworkActivityIndicatorManager Class Reference

Inherits from NSObject
Declared in AFNetworkActivityIndicatorManager.h
AFNetworkActivityIndicatorManager.m

Overview

AFNetworkActivityIndicatorManager manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.

You should enable the shared instance of AFNetworkActivityIndicatorManager when your application finishes launching. In AppDelegate application:didFinishLaunchingWithOptions: you can do so with the following code:

[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];

By setting enabled to YES for sharedManager, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call incrementActivityCount or decrementActivityCount yourself.

See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44

  enabled

A Boolean value indicating whether the manager is enabled.

@property (nonatomic, assign, getter=isEnabled) BOOL enabled

Discussion

If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.

Declared In

AFNetworkActivityIndicatorManager.h

  networkActivityIndicatorVisible

A Boolean value indicating whether the network activity indicator manager is currently active.

@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible

Declared In

AFNetworkActivityIndicatorManager.h

  activationDelay

A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds.

@property (nonatomic, assign) NSTimeInterval activationDelay

Discussion

Apple’s HIG describes the following:

Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence.

Declared In

AFNetworkActivityIndicatorManager.h

  completionDelay

A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds.

@property (nonatomic, assign) NSTimeInterval completionDelay

Declared In

AFNetworkActivityIndicatorManager.h

+ sharedManager

Returns the shared network activity indicator manager object for the system.

+ (instancetype)sharedManager

Return Value

The systemwide network activity indicator manager.

Declared In

AFNetworkActivityIndicatorManager.h

– incrementActivityCount

Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.

- (void)incrementActivityCount

Declared In

AFNetworkActivityIndicatorManager.h

– decrementActivityCount

Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.

- (void)decrementActivityCount

Declared In

AFNetworkActivityIndicatorManager.h

– setNetworkingActivityActionWithBlock:

Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward.

- (void)setNetworkingActivityActionWithBlock:(nullable void ( ^ ) ( BOOL networkActivityIndicatorVisible ))block

Parameters

block

A block to be executed when the network activity indicator status changes.

Declared In

AFNetworkActivityIndicatorManager.h

UIActivityIndicatorView(AFNetworking) Category Reference

UIActivityIndicatorView(AFNetworking) Category Reference

Declared in UIActivityIndicatorView+AFNetworking.h
UIActivityIndicatorView+AFNetworking.m

Overview

This category adds methods to the UIKit framework’s UIActivityIndicatorView class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.

Animating for Session Tasks

– setAnimatingWithStateOfTask:

Binds the animating state to the state of the specified task.

- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task

Parameters

task

The task. If nil, automatic updating from any previously specified operation will be disabled.

Declared In

UIActivityIndicatorView+AFNetworking.h

AFPropertyListResponseSerializer Class Reference

AFPropertyListResponseSerializer Class Reference

Inherits from AFHTTPResponseSerializer : NSObject
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFPropertyListResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes XML responses as an NSXMLDocument objects.

By default, AFPropertyListResponseSerializer accepts the following MIME types:

  • application/x-plist

Other Methods

  format

The property list format. Possible values are described in “NSPropertyListFormat”.

@property (nonatomic, assign) NSPropertyListFormat format

Declared In

AFURLResponseSerialization.h

  readOptions

The property list reading options. Possible values are described in “NSPropertyListMutabilityOptions.”

@property (nonatomic, assign) NSPropertyListReadOptions readOptions

Declared In

AFURLResponseSerialization.h

+ serializerWithFormat:readOptions:

Creates and returns a property list serializer with a specified format, read options, and write options.

+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format readOptions:(NSPropertyListReadOptions)readOptions

Parameters

format

The property list format.

readOptions

The property list reading options.

Declared In

AFURLResponseSerialization.h

Other Methods

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLResponseSerialization.h

AFQueryStringPair Class Reference

AFQueryStringPair Class Reference

Inherits from NSObject
Declared in AFURLRequestSerialization.m

Overview

Returns a percent-escaped string following RFC 3986 for a query string key or value. RFC 3986 states that the following characters are “reserved” characters. - General Delimiters: “:”, “#”, “[”, “]”, “@”, “?”, “/” - Sub-Delimiters: “!”, “$”, “&”, “‘”, “(”, “)”, “*”, “+”, “,”, “;”, “=”

In RFC 3986 - Section 3.4, it states that the “?” and “/” characters should not be escaped to allow query strings to include a URL. Therefore, all “reserved” characters with the exception of “?” and “/” should be percent-escaped in the query string. - parameter string: The string to be percent-escaped. - returns: The percent-escaped string.

AFSecurityPolicy Class Reference

AFSecurityPolicy Class Reference

Inherits from NSObject
Conforms to NSCopying
NSSecureCoding
Declared in AFSecurityPolicy.h
AFSecurityPolicy.m

Overview

AFSecurityPolicy evaluates server trust against pinned X.509 certificates and public keys over secure connections.

Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.

Other Methods

  SSLPinningMode

The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to AFSSLPinningModeNone.

@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode

Declared In

AFSecurityPolicy.h

  pinnedCertificates

The certificates used to evaluate server trust according to the SSL pinning mode.

@property (nonatomic, strong, nullable) NSSet<NSData*> *pinnedCertificates

Discussion

By default, this property is set to any (.cer) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use certificatesInBundle to load certificates from your target, and then create a new policy by calling policyWithPinningMode:withPinnedCertificates.

Note that if pinning is enabled, evaluateServerTrust:forDomain: will return true if any pinned certificate matches.

Declared In

AFSecurityPolicy.h

  allowInvalidCertificates

Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to NO.

@property (nonatomic, assign) BOOL allowInvalidCertificates

Declared In

AFSecurityPolicy.h

  validatesDomainName

Whether or not to validate the domain name in the certificate’s CN field. Defaults to YES.

@property (nonatomic, assign) BOOL validatesDomainName

Declared In

AFSecurityPolicy.h

Getting Certificates from the Bundle

+ certificatesInBundle:

Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling policyWithPinningMode:withPinnedCertificates.

+ (NSSet<NSData*> *)certificatesInBundle:(NSBundle *)bundle

Return Value

The certificates included in the given bundle.

Declared In

AFSecurityPolicy.h

Getting Specific Security Policies

+ defaultPolicy

Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.

+ (instancetype)defaultPolicy

Return Value

The default security policy.

Declared In

AFSecurityPolicy.h

Initialization

+ policyWithPinningMode:

Creates and returns a security policy with the specified pinning mode.

+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode

Parameters

pinningMode

The SSL pinning mode.

Return Value

A new security policy.

Declared In

AFSecurityPolicy.h

+ policyWithPinningMode:withPinnedCertificates:

Creates and returns a security policy with the specified pinning mode.

+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet<NSData*> *)pinnedCertificates

Parameters

pinningMode

The SSL pinning mode.

pinnedCertificates

The certificates to pin against.

Return Value

A new security policy.

Declared In

AFSecurityPolicy.h

Evaluating Server Trust

– evaluateServerTrust:forDomain:

Whether or not the specified server trust should be accepted, based on the security policy.

- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust forDomain:(nullable NSString *)domain

Parameters

serverTrust

The X.509 certificate trust of the server.

domain

The domain of serverTrust. If nil, the domain will not be validated.

Return Value

Whether or not to trust the server.

Discussion

This method should be used when responding to an authentication challenge from a server.

Declared In

AFSecurityPolicy.h

AFPropertyListRequestSerializer Class Reference

AFPropertyListRequestSerializer Class Reference

Inherits from AFHTTPRequestSerializer : NSObject
Declared in AFURLRequestSerialization.h
AFURLRequestSerialization.m

Overview

AFPropertyListRequestSerializer is a subclass of AFHTTPRequestSerializer that encodes parameters as JSON using NSPropertyListSerializer, setting the Content-Type of the encoded request to application/x-plist.

Other Methods

  format

The property list format. Possible values are described in “NSPropertyListFormat”.

@property (nonatomic, assign) NSPropertyListFormat format

Declared In

AFURLRequestSerialization.h

  writeOptions

The writeOptions property is currently unused.

@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions

Discussion

Warning: The writeOptions property is currently unused.

Declared In

AFURLRequestSerialization.h

+ serializerWithFormat:writeOptions:

Creates and returns a property list serializer with a specified format, read options, and write options.

+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format writeOptions:(NSPropertyListWriteOptions)writeOptions

Parameters

format

The property list format.

writeOptions

The property list write options.

Discussion

Warning: The writeOptions property is currently unused.

Declared In

AFURLRequestSerialization.h

Other Methods

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLRequestSerialization.h

AFXMLDocumentResponseSerializer Class Reference

AFXMLDocumentResponseSerializer Class Reference

Inherits from AFHTTPResponseSerializer : NSObject
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFXMLDocumentResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes XML responses as an NSXMLDocument objects.

By default, AFXMLDocumentResponseSerializer accepts the following MIME types, which includes the official standard, application/xml, as well as other commonly-used types:

  • application/xml
  • text/xml

Other Methods

  options

Input and output options specifically intended for NSXMLDocument objects. For possible values, see the NSJSONSerialization documentation section “NSJSONReadingOptions”. 0 by default.

@property (nonatomic, assign) NSUInteger options

Declared In

AFURLResponseSerialization.h

+ serializerWithXMLDocumentOptions:

Creates and returns an XML document serializer with the specified options.

+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask

Parameters

mask

The XML document options.

Declared In

AFURLResponseSerialization.h

Other Methods

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLResponseSerialization.h

– responseObjectForResponse:data:error:

- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error

Declared In

AFURLResponseSerialization.h

CTRemoteLogger Class Reference

CTRemoteLogger Class Reference

Inherits from NSObject
Declared in CTRemoteLogger.h
CTRemoteLogger.m

– writeLogWithActionId:appId:ucid:extParams:

This module can both mark log onto local Storage and can sync local log to log server

- (void)writeLogWithActionId:(NSString *)actionId appId:(NSString *)appId ucid:(NSString *)ucid extParams:(NSMutableArray *)params

Parameters

actionId

ID of actions, such as Event, Clicked, Submitted, Callback,etc.

appId

ID of app, identifier of each application

ucid

ID of usecase, the identifier of each usecase, as the further tag on Log Search System

params

other params,Array,only support up to 4 elements.

Availability

iOS9.0

Discussion

Add behavior log onto local storage and sync to log server when:

  • Enter the app

  • Enter the background

  • Every 2 mins

  • When log number reach to 100

  • When log file size > 5MB

This is sample code:

[[[CTRemoteLogger alloc] init] writeLogWithActionId:@“yourActionID” appId:@“yourAppId” ucid:@“yourUCID” extParams:@[@“param1”,@“param2”]];

Declared In

CTRemoteLogger.h