• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Protocol + Delegate = conflict types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Protocol + Delegate = conflict types


  • Subject: Protocol + Delegate = conflict types
  • From: "Christian Giordano" <email@hidden>
  • Date: Fri, 16 Jan 2009 08:38:35 +0000

Hi guys, I'm trying to implement the Delegate pattern and I would like
a delegate that works like NSURLConnection where any method of the
delegate returns itself. The problem I have is that if I specify its
type in the methods parameters instead of "id":

// RemoteLoader.h
@protocol RemoteLoaderDelegate
-(void) onLoadingFail:(RemoteLoader *)loader;
-(void) onLoadingFinish:(RemoteLoader *)loader;
-(void) onLoadingProgress:(RemoteLoader *)loader;
@end

@interface RemoteLoader : NSObject
{
	...
}
...
@end

I get: "error: syntax error before 'RemoteLoader'"


If I leave "id" in the protocol definition:

@protocol RemoteLoaderDelegate
-(void) onLoadingFail:(id)loader;
-(void) onLoadingFinish:(id)loader;
-(void) onLoadingProgress:(id)loader;
@end

but leave the typed parameter in the implemented methods:

-(void) onLoadingFail:(RemoteLoader *)loader
{
	...
}

I get: "warning: conflicting types for
'-(void)onLoadingFail:(RemoteLoader *)loader'" but it works.


Is there a way to implement this typed delegation without warning errors?


Thanks for any suggestion, chr
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Protocol + Delegate = conflict types
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: ObjC in time-critical parts of the code
  • Next by Date: Re: ObjC in time-critical parts of the code
  • Previous by thread: Re: Cocoa-dev Digest, Vol 6, Issue 86
  • Next by thread: Re: Protocol + Delegate = conflict types
  • Index(es):
    • Date
    • Thread