Up
Authors
- Mike Kienenberger
-
Version: 27578
Date: 2009-01-12 12:48:46 +0000 (Mon, 12 Jan 2009)
Copyright: (C) 1995 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSProtocolChecker.h
Availability: OpenStep
The NSProtocolChecker and NSProxy classes provide message
filtering and forwarding capabilities. If you wish
to ensure at runtime that a given object will only be sent
messages in a certain protocol, you create an
NSProtocolChecker
instance with the
protocol and the object as arguments-
id versatileObject = [[ClassWithManyMethods alloc] init];
id narrowObject = [NSProtocolChecker protocolCheckerWithTarget: versatileObject
protocol: @protocol(SomeSpecificProtocol)];
return narrowObject;
This is often used in conjunction with distributed
objects to expose only a subset of an objects methods
to remote processes
Instance Variables
Method summary
+ (id)
protocolCheckerWithTarget: (
NSObject*)anObject
protocol: (Protocol*)aProtocol;
Availability: OpenStep
Allocates and initializes an NSProtocolChecker
instance by calling
-initWithTarget:protocol:
Autoreleases and returns the new instance.
- (void)
forwardInvocation: (
NSInvocation*)anInvocation;
Availability: OpenStep
Forwards any message to the delegate if the method
is declared in the checker's protocol; otherwise raises
an NSInvalidArgumentException
.
- (id)
initWithTarget: (
NSObject*)anObject
protocol: (Protocol*)aProtocol;
Availability: OpenStep
Initializes a newly allocated NSProtocolChecker
instance that will forward any messages in the
aProtocol protocol to anObject,
its delegate. Thus, the checker can be vended in lieu
of anObject to restrict the messages that can
be sent to anObject. If any method in the
protocol returns anObject, the checker
will replace the returned value with itself rather
than the target object.
Returns the new
instance.
- (Protocol*)
protocol;
Availability: OpenStep
Returns the protocol object the checker uses to
verify whether a given message should be forwarded
to its delegate.
- (
NSObject*)
target;
Availability: OpenStep
Returns the target of the NSProtocolChecker.
Instance Variables for NSProtocolChecker Class
@protected Protocol* _myProtocol;
Availability: OpenStep
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.
@protected NSObject* _myTarget;
Availability: OpenStep
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.
Up