Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Formal Protocols

Formal protocols are declared using the @protocol directive:

@protocol ProtocolName < protocol list >
method declarations
@end

The list of incorporated protocols and the method declarations are optional. The protocol must import the header files that declare any protocols it incorporates.

You can create a forward reference to a protocol using the @protocol directive in the following manner:

@protocol ProtocolName;

Within source code, protocols are referred to using the similar @protocol() directive, where the parentheses enclose the protocol name.

Protocol names listed within angle brackets (<...>) are used to do three different things:

Within protocol declarations, these type qualifiers support remote messaging:

Type Qualifier

Definition

oneway

The method is for asynchronous messages and has no valid return type.

in

The argument passes information to the remote receiver.

out

The argument gets information returned by reference.

inout

The argument both passes information and gets information.

bycopy

A copy of the object, not a proxy, should be passed or returned.

byref

A reference to the object, not a copy, should be passed or returned.



< Previous PageNext Page > Hide TOC


Last updated: 2008-02-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice