NSConnectionDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.6 and later.
Companion guide
Declared in
NSConnection.h
Related sample code

Overview

The NSConnectionDelegate protocol defines the optional methods implemented by delegates of NSConnection objects.

Tasks

Authenticating

Responding to a Connection

Instance Methods

authenticateComponents:withData:

Returns a Boolean value that indicates whether given authentication data is valid for a given set of components.

- (BOOL)authenticateComponents:(NSArray *)components withData:(NSData *)authenticationData
Parameters
components

An array that contains NSData and NSPort objects belonging to an NSPortMessage object. See the NSPortMessage class specification for more information.

authenticationData

Authentication data created by the delegate of the peer NSConnection object with authenticationDataForComponents:.

Return Value

YES if the authenticationData provided is valid for components, otherwise NO.

Discussion

Use this message for validation of incoming messages. An NSConnection object raises an NSFailedAuthenticationException on receipt of a remote message the delegate doesn’t authenticate.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSConnection.h

authenticationDataForComponents:

Returns an NSData object to be used as an authentication stamp for an outgoing message.

- (NSData *)authenticationDataForComponents:(NSArray *)components
Parameters
components

An array containing the elements of a network message, in the form of NSPort and NSData objects.

Return Value

An NSData object to be used as an authentication stamp for an outgoing message.

Discussion

The delegate should use only the NSData elements to create the authentication stamp. See the NSPortMessage class specification for more information on the components.

If authenticationDataForComponents: returns nil, an NSGenericException will be raised. If the delegate determines that the message shouldn’t be authenticated, it should return an empty NSData object. The delegate on the other side of the connection must then be prepared to accept an empty NSData object as the second parameter to authenticateComponents:withData: and to handle the situation appropriately.

The components parameter will be validated on receipt by the delegate of the peer NSConnection object with authenticateComponents:withData:.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSConnection.h

connection:handleRequest:

This method should be implemented by NSConnection object delegates that want to intercept distant object requests.

- (BOOL)connection:(NSConnection *)conn handleRequest:(NSDistantObjectRequest *)doReq
Parameters
conn

The connection object for which the receiver is the delegate.

doReq

The distant object request.

Return Value

YES if the request was handled by the delegate, NO if the request should proceed as if the delegate did not intercept it.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSConnection.h

connection:shouldMakeNewConnection:

Returns a Boolean value that indicates whether the parent connection should allow a given new connection to be created.

- (BOOL)connection:(NSConnection *)parentConnection shouldMakeNewConnection:(NSConnection *)newConnnection
Parameters
parentConnection

The connection object for which the receiver is the delegate.

newConnnection

The new connection.

Return Value

YES if parentConnection should allow newConnnection to be created and set up, NO if parentConnection should refuse and immediately release newConnection.

Discussion

Use this method to limit the amount of NSConnection objects created in your application or to change the parameters of child NSConnection objects.

Use NSConnectionDidInitializeNotification instead of this delegate method if possible.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSConnection.h

createConversationForConnection:

Returns an arbitrary object identifying a new conversation being created for the connection in the current thread.

- (id)createConversationForConnection:(NSConnection *)conn
Parameters
conn

The connection object for which the receiver is the delegate.

Return Value

An arbitrary object identifying a new conversation being created for the connection in the current thread.

Discussion

New conversations are created only if independentConversationQueueing is YES for conn. If you do not implement this method, NSConnection object creates an instance of NSObject.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSConnection.h

makeNewConnection:sender:

Returns a Boolean value that indicates whether the parent should allow a given new connection to be created and configured.

- (BOOL)makeNewConnection:(NSConnection *)newConnection sender:(NSConnection *)parentConnection
Parameters
newConnection

The new connection.

parentConnection

The parent connection.

Return Value

YES if parentConnection should allow newConnnection to be created and configured, NO if parentConnection should refuse and immediately release newConnection.

Discussion

Use this method to limit the number of NSConnection objects created in your application or to change the parameters of child NSConnection objects.

Use NSConnectionDidInitializeNotification instead of this delegate method if possible.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSConnection.h