Representation of a protocols.
More...
#import <SCRuntimeProtocol.h>
Representation of a protocols.
- SDK
- macOS 10.6+, iOS 7.0+, GNUstep
- Since
- version 1.2.6
Provides access to runtime protocols:
- getting information about registered protocols;
- creating new protocols;
- access to the properties and methods declared in the protocols;
- communicating with classes and another protocols.
Class instances can thrown the following exceptions:
- (BOOL) addToClass: |
|
(Class) |
class |
|
Adds the receiving protocol to a given existing class.
- Parameters
-
- Returns
- YES if a protocol was added successfully, otherwise NO
- Exceptions
-
- SDK
- macOS 10.6+, iOS 7.0+
Adds the receiving protocol to a given unregistered protocol.
- Warning
- On GNUstep platform a method was removing all previously added protocols.
- Parameters
-
protocol | - an unregistered protocol |
- Exceptions
-
Adds the receiving protocol to a given unregistered class.
- Parameters
-
class | - an unregistered class |
- Returns
- YES if a protocol was added successfully, otherwise NO
- Exceptions
-
- (NSArray *) adoptedProtocols |
|
|
|
Returns a list of adopted protocols.
- Returns
- An array of protocols
+ (NSArray *) allProtocols |
|
|
|
Returns a list of all registered protocols.
- Returns
- An array of protocols
- (BOOL) conformedClass: |
|
(Class) |
class |
|
Returns a boolean value that indicates whether a given class is conformed to the receiving protocol.
- Parameters
-
- Returns
- YES if a given class is conformed to the receiving protocol, otherwise NO
Returns a boolean value that indicates whether a given unregistered class is conformed to the receiving protocol.
- Parameters
-
class | - an unregistered class |
- Returns
- YES if a given unregistered class is conformed to the receiving protocol, otherwise NO
- (BOOL) conformsToProtocolWithName: |
|
(NSString *) |
name |
|
Returns a boolean value that indicates whether the receiving protocol conforms to a protocol with a given name.
- Parameters
-
- Returns
- YES if the receiving protocol conforms to a protocol with a given name, otherwise NO
Returns a boolean value that indicates whether the receiving protocol conforms to a given protocol.
- Parameters
-
- Returns
- YES if the receiving protocol conforms to a given protocol, otherwise NO
- (BOOL) containsMethod: |
|
(SCRuntimeMethod *) |
method |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a boolean value that indicates whether the receiving protocol contains a given method.
- Parameters
-
method | - a method |
required | - YES for a required protocol method, NO for an optional protocol method |
instance | - YES for an instance method, NO for a class method |
- Returns
- YES if the receiving protocol contains a given method, otherwise NO
- (BOOL) containsMethodWithSelector: |
|
(SEL) |
selector |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a boolean value that indicates whether the receiving protocol contains a method with a given selector.
- Parameters
-
selector | - a method selector |
required | - YES for a required protocol method, NO for an optional protocol method |
instance | - YES for an instance method, NO for a class method |
- Returns
- YES if the receiving protocol contains a method with a given selector, otherwise NO
- (BOOL) containsProperty: |
|
(SCRuntimeProperty *) |
property |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a boolean value that indicates whether the receiving protocol contains a given property.
- Attention
- Class properties are supported only on macOS and iOS platforms. When this method is called on the GNUstep platform, the instance parameter value is ignored and the method always works only with instance properties.
- Parameters
-
property | - a property |
required | - YES for a required protocol property, NO for an optional protocol property |
instance | - YES for an instance property, NO for a class property (ignored on GNUstep platform) |
- Returns
- YES if the receiving protocol contains a given property, otherwise NO
- (BOOL) containsPropertyWithName: |
|
(NSString *) |
name |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a boolean value that indicates whether the receiving protocol contains a property with a given name.
- Attention
- Class properties are supported only on macOS and iOS platforms. When this method is called on the GNUstep platform, the instance parameter value is ignored and the method always works only with instance properties.
- Parameters
-
name | - a property name |
required | - YES for a required protocol property, NO for an optional protocol property |
instance | - YES for an instance property, NO for a class property (ignored on GNUstep platform) |
- Returns
- YES if the receiving protocol contains a property with a given name, otherwise NO
- (instancetype) initWithName: |
|
(NSString *) |
name |
|
Initializes a protocol using a given protocol name.
- Parameters
-
- Returns
- A newly initialized protocol
Reimplemented in SCRuntimeUnregisteredProtocol.
- (instancetype) initWithObjCProtocol: |
|
(Protocol *) |
protocol |
|
Initializes a protocol using a given pointer to existing runtime protocol.
- Parameters
-
protocol | - a pointer to runtime protocol |
- Returns
- A newly initialized protocol
- (BOOL) isEqual: |
|
(id) |
object |
|
Returns a boolean value that indicates whether the receiving protocol is equals to a given object.
- Parameters
-
object | - an object with which to compare the receiving protocol |
- Returns
- YES if a given object is equals to the receiving protocol, otherwise NO
Reimplemented from SCObject.
- (BOOL) isEqualToName: |
|
(NSString *) |
name |
|
Returns a boolean value that indicates whether the receiving protocol is equals to a protocol with a given name.
- Parameters
-
name | - a name of protocol with which to compare the receiving protocol |
- Returns
- YES if the protocol with a given name is equals to the receiving protocol, otherwise NO
- (BOOL) isEqualToObjCProtocol: |
|
(Protocol *) |
protocol |
|
Returns a boolean value that indicates whether the receiving protocol is equals to a pointer to runtime protocol.
- Parameters
-
protocol | - a pointer to runtime protocol with which to compare the receiving protocol |
- Returns
- YES if a protocol with a given runtime pointer is equals to the receiving protocol, otherwise NO
Returns a boolean value that indicates whether the receiving protocol is equals to an another given protocol.
- Parameters
-
protocol | - the protocol with which to compare the receiving protocol |
- Returns
- YES if the other protocol is equals to the receiving protocol, otherwise NO
Returns a list of all protocol methods.
- Returns
- An array of methods
- (NSArray *) methodsRequired: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a list of receiving protocol methods with a given flags.
- Parameters
-
required | - YES for a required methods, NO for an optional methods |
instance | - YES for an instance methods, NO for a class methods |
- Returns
- An array of methods
- (SCRuntimeMethod *) methodWithSelector: |
|
(SEL) |
selector |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a protocol method with a given selector and flags.
- Parameters
-
selector | - a method selector |
required | - YES for a required method, NO for an optional method |
instance | - YES for an instance method, NO for a class method |
- Returns
- A protocol method with a given selector or nil if a method does not exists in a receving protocol
- Exceptions
-
Returns a list of receiving protocol properties.
- Returns
- An array of properties
- (SCRuntimeProperty *) propertyWithName: |
|
(NSString *) |
name |
required: |
|
(BOOL) |
required |
instance: |
|
(BOOL) |
instance |
|
|
| |
Returns a receiving protocol property with a given name, required flag and instance flag.
- Attention
- Class properties are supported only on macOS and iOS platforms. When this method is called on the GNUstep platform, the instance parameter value is ignored and the method always works only with instance properties.
- Parameters
-
name | - a property name |
required | - YES for a required protocol property, NO for an optional protocol property |
instance | - YES for an instance property, NO for a class property (ignored on GNUstep platform) |
- Returns
- A required property or nil if a receiving protocol does not contain a property with a given name
- Exceptions
-
+ (instancetype) protocolWithName: |
|
(NSString *) |
name |
|
+ (instancetype) protocolWithObjCProtocol: |
|
(Protocol *) |
protocol |
|
Returns a protocol created by using a given pointer to existing runtime protocol.
- Parameters
-
protocol | - a pointer to runtime protocol |
- Returns
- A created protocol
The documentation for this class was generated from the following files: