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
Post a Comment