• 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
Re: Types for the method have to conform?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Types for the method have to conform?


  • Subject: Re: Types for the method have to conform?
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 10 Aug 2005 22:04:58 -0400

On Aug 10, 2005, at 9:11 PM, John Calsbeek wrote:

I've got a method declared as follows:

- (id)initWithData:(NSData *)data options:(NSDictionary *)options error:(NSError **)errorPtr;

I've been running into a certain problem in which gcc seems to think that the actual signature is:

- (id)initWithData:(NSData *)data options:(unsigned int)options error:(NSError **)errorPtr;

because every other method using the selector initWithData:options:error: uses that signature. Will I be perpetually haunted by those warnings when I compile, or will I have to switch to an unsigned int for options?

You need to declare the type of the object you're sending these messages to. If you declare it as "id", you'll get warnings because the compiler finds multiple signatures and doesn't know which one applies.


In other words, instead of writing this:

    id foo = [[FooMatic alloc] initWithData ...];

Write it like this:

    FooMatic *foo = [[FooMatic alloc] initWithData ...];

That way the compiler knows to use the signature found in the FooMatic class for that method.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Types for the method have to conform?
      • From: Jack Nutting <email@hidden>
References: 
 >Types for the method have to conform? (From: John Calsbeek <email@hidden>)

  • Prev by Date: Re: NSUserDefaults and thread safety
  • Next by Date: Re: Option-click on my app hides the other app
  • Previous by thread: Types for the method have to conform?
  • Next by thread: Re: Types for the method have to conform?
  • Index(es):
    • Date
    • Thread