Function

protocol_addProperty(_:_:_:_:_:_:)

Adds a property to a protocol that is under construction.

Declaration

func protocol_addProperty(_ proto: Protocol, _ name: UnsafePointer<Int8>, _ attributes: UnsafePointer<objc_property_attribute_t>?, _ attributeCount: UInt32, _ isRequiredProperty: Bool, _ isInstanceProperty: Bool)

Parameters

proto

The protocol you want to add a property to.

name

The name of the property you want to add.

attributes

An array of property attributes.

attributeCount

The number of properties in attributes.

isRequiredProperty

A Boolean indicating whether the property’s accessor methods are required methods of the proto protocol. If true, the property’s accessor methods are required methods; if false, the property’s accessor methods are optional methods.

isInstanceProperty

A Boolean indicating whether the property’s accessor methods are instance methods. If true, the property’s accessor methods are instance methods. true is the only value allowed for a property. As a result, if you set this value to false, the property will not be added to the protocol.

Discussion

The protocol you want to add the property to must be under construction—allocated but not yet registered with the Objective-C runtime (via the objc_registerProtocol(_:) function).

See Also

Working with Protocols

func objc_registerProtocol(Protocol)

Registers a newly created protocol with the Objective-C runtime.

func protocol_addProtocol(Protocol, Protocol)

Adds a registered protocol to another protocol that is under construction.

func protocol_isEqual(Protocol?, Protocol?) -> Bool

Returns a Boolean value that indicates whether two protocols are equal.

func protocol_copyMethodDescriptionList(Protocol, Bool, Bool, UnsafeMutablePointer<UInt32>?) -> UnsafeMutablePointer<objc_method_description>?

Returns an array of method descriptions of methods meeting a given specification for a given protocol.

func protocol_getMethodDescription(Protocol, Selector, Bool, Bool) -> objc_method_description

Returns a method description structure for a specified method of a given protocol.

func protocol_conformsToProtocol(Protocol?, Protocol?) -> Bool

Returns a Boolean value that indicates whether one protocol conforms to another protocol.