J'ai rencontré cette erreur en essayant de référencer un protocole que j'avais moi-même mis en place.
Ceci montre mon protocole, la mauvaise méthode et ce que je pense être la bonne méthode.
in .h
// ------------------------------------ EtEmailDelegate Protocol -BEGIN- --------------------------------------
@protocol EtEmailDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error; //<-- This is really just one chunk from the MFMailComposeViewControllerDelegate
@end
// ------------------------------------ EtEmailDelegate Protocol -END- --------------------------------------
@interface ClsEtEmail : NSObject < MFMailComposeViewControllerDelegate> {
// owner
UIViewController *myUivc;
//EtEmailDelegate *myDelegate; // <--- the wrong way, throw error
id<EtEmailDelegate> *myDelegate; // <-- the right way (i think)
...
}
@property (nonatomic, readwrite, assign) id<EtEmailDelegate> delegate;
@end
Juste pour être complet, voici comment je mettre en œuvre des méthodes qui reposent également sur le protocole ...
in .m
@synthesize delegate = myDelegate;
// my static initializer
+(id) objEtEmailWithUivc: (UIViewController*) theUivc delegate: (id <EtEmailDelegate>) theDelegate {
ClsEtEmail * obj = [[[ClsEtEmail alloc] initWithlUivc: theUivc delegate:theDelegate] autorelease];
return obj;
}
// my normal init
- (id)initWithlUivc: (UIViewController*) theUivc delegate: (id <EtEmailDelegate>) theDelegate {
self = [super init];
if (self) {
[self init_]; // my private init (not seen)
self.uivc = theUivc;
NSAssert([theDelegate conformsToProtocol:@protocol(EtEmailDelegate)],@"whoh - this can't is notE tEmailDelegate");
self.delegate = theDelegate;
}
return self;
}
Hope this helps quelqu'un d'autre.
PolygonShape et PolygonView ont probablement des importations cycliques. C'est pourquoi les déclarations anticipées existent. Utilisez-les, s'il vous plaît. –
PolygonShape et PolygonView n'ont pas eu d'importations cycliques, mais PolygonView et Controller l'ont fait. Merci pour l'aide! – Ridwan
@Jason: Cela ferait probablement une bonne réponse. – Chuck