Up

NSURLConnection class documentation

Authors

Generated by fedor

Contents -

  1. Software documentation for the NSURLConnection class
  2. Software documentation for the NSObject(NSURLConnectionDelegate) category
  3. Software documentation for the NSURLConnection(NSURLConnectionSynchronousLoading) category

Software documentation for the NSURLConnection class

NSURLConnection : NSObject

Declared in:
Foundation/NSURLConnection.h
Availability: MacOS-X 10.2.0, Base 1.13.0

Description forthcoming.

Instance Variables

Method summary

canHandleRequest: 

+ (BOOL) canHandleRequest: (NSURLRequest*)request;
Availability: MacOS-X 10.2.0, Base 1.13.0

Performs a preliminary check to see if a load of the specified request can be handled by an instance of this class.
The results of this method may be invalidated by subsequent changes to the request or changes to the registered protocols etc.

connectionWithRequest: delegate: 

+ (NSURLConnection*) connectionWithRequest: (NSURLRequest*)request delegate: (id)delegate;
Availability: MacOS-X 10.2.0, Base 1.13.0

Allocates and returns the autoreleased instance which it initialises using the -initWithRequest:delegate: method.

cancel 

- (void) cancel;
Availability: MacOS-X 10.2.0, Base 1.13.0

Cancel the asynchronous load in progress (if any) for this connection.

initWithRequest: delegate: 

- (id) initWithRequest: (NSURLRequest*)request delegate: (id)delegate;
Availability: MacOS-X 10.2.0, Base 1.13.0

This is a designated initialiser for the class.
Initialises the receiver with the specified request (performing a deep copy so that the request does not change during loading) and delegate.
This automatically initiates an asynchronous load for the request.
Processing of the request is done in the thread which calls this method, so the thread must run its current run loop (in NSDefaultRunLoopMode) for processing to continue/complete.
The delegate will receive callbacks informing it of the progress of the load.
This method breaks with convention and retains the delegate object, releasing it when the connection finished loading, fails, or is cancelled.



Instance Variables for NSURLConnection Class

_NSURLConnectionInternal

@protected void* _NSURLConnectionInternal;
Availability: MacOS-X 10.2.0, Base 1.13.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.




Software documentation for the NSObject(NSURLConnectionDelegate) category

NSObject(NSURLConnectionDelegate)

Declared in:
Foundation/NSURLConnection.h
Availability: MacOS-X 10.2.0, Base 1.13.0

This category is an informal protocol specifying how an NSURLConnection instance will communicate with its delegate to inform it of (and allow it to manage) the progress of a load request.
A load operation is performed by asynchronous I/O using the run loop of the thread in which it was initiated, so all callbacks will occur in that thread.
The process of loading a resource occurs as follows -
Method summary

connection: didCancelAuthenticationChallenge: 

- (void) connection: (NSURLConnection*)connection didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
Availability: MacOS-X 10.2.0, Base 1.13.0

Instructs the delegate that authentication for challenge has been cancelled for the request loading on connection.

connection: didFailWithError: 

- (void) connection: (NSURLConnection*)connection didFailWithError: (NSError*)error;
Availability: MacOS-X 10.2.0, Base 1.13.0

Description forthcoming.

connection: didReceiveAuthenticationChallenge: 

- (void) connection: (NSURLConnection*)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
Availability: MacOS-X 10.2.0, Base 1.13.0

Called when an authentication challenge is received... the delegate should send -useCredential:forAuthenticationChallenge: or -continueWithoutCredentialForAuthenticationChallenge: or -cancelAuthenticationChallenge: to the challenge sender when done.

connection: didReceiveData: 

- (void) connection: (NSURLConnection*)connection didReceiveData: (NSData*)data;
Availability: MacOS-X 10.2.0, Base 1.13.0

Called when content data arrives during a load operations... this may be incremental or may be the compolete data for the load.

connection: didReceiveResponse: 

- (void) connection: (NSURLConnection*)connection didReceiveResponse: (NSURLResponse*)response;
Availability: MacOS-X 10.2.0, Base 1.13.0

Called when enough information to build a NSURLResponse object has been received.

connection: willCacheResponse: 

- (NSCachedURLResponse*) connection: (NSURLConnection*)connection willCacheResponse: (NSCachedURLResponse*)cachedResponse;
Availability: MacOS-X 10.2.0, Base 1.13.0

Called with the cachedResponse to be stored in the cache. The delegate can inspect the cachedResponse and return a modified copy if if wants changed to what whill be stored.
If it returns nil, nothing will be stored in the cache.

connection: willSendRequest: redirectResponse: 

- (NSURLRequest*) connection: (NSURLConnection*)connection willSendRequest: (NSURLRequest*)request redirectResponse: (NSURLResponse*)response;
Availability: MacOS-X 10.2.0, Base 1.13.0

Informs the delegate that the connection must change the URL of the request in order to continue with the load operation.
This allows the delegate to ionspect and/or modify a copy of the request before the connection continues loading it. Normally the delegate can return the request unmodifield.
The redirection can be rejectected by the delegate calling -cancel or returning nil.
Cancelling the load will simply stop it, but returning nil will cause it to complete with a redirection failure.
As a special case, this method may be called with a nil response, indicating a change of URL made internally by the system rather than due to a response from the server.

connectionDidFinishLoading: 

- (void) connectionDidFinishLoading: (NSURLConnection*)connection;
Availability: MacOS-X 10.2.0, Base 1.13.0

Called when an NSURLConnection has finished loading successfully.

Software documentation for the NSURLConnection(NSURLConnectionSynchronousLoading) category

NSURLConnection(NSURLConnectionSynchronousLoading)

Declared in:
Foundation/NSURLConnection.h
Availability: MacOS-X 10.2.0, Base 1.13.0

An interface to perform synchronous loading of URL requests.
Method summary

sendSynchronousRequest: returningResponse: error: 

+ (NSData*) sendSynchronousRequest: (NSURLRequest*)request returningResponse: (NSURLResponse**)response error: (NSError**)error;
Availability: MacOS-X 10.2.0, Base 1.13.0

Performs a synchronous load of request and returns the NSURLResponse in response.
Returns the result of the load or nil if the load failed.


Up