objective c - Declaring protocol like @class -


i have 2 protocols communicating each other. defined in same file.

@protocol protocol1 <nsobject> -(void)setprotocoldelegate:(id<protocol2>)delegate; @end  @protocol protocol2 <nsobject> -(void)protocol:(uiviewcontroller<protocol1>*)anobject chosenelementatindex:(nsinteger)aindex; @end 

how declare empty protocol protocol2 let know compiler declared later?

if protocol2 class i'd write @class protocol2; beforewards.

@class protocol2; @protocol protocol1 <nsobject> -(void)setprotocoldelegate:(protocol2*)delegate; @end  @interface protocol2 <nsobject> -(void)protocol:(uiviewcontroller<protocol1>*)anobject chosenelementatindex:(nsinteger)aindex; @end 

what similar construction protocols?

use @protocol protocols forward declaration:

@protocol protocol2; @protocol protocol1 <nsobject> -(void)setprotocoldelegate:(id<protocol2>)delegate; @end  @protocol protocol2 <nsobject> -(void)protocol:(uiviewcontroller<protocol1>*)anobject chosenelementatindex:(nsinteger)aindex; @end 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -