• 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: confused about inheritance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: confused about inheritance


  • Subject: Re: confused about inheritance
  • From: Ivan Kourtev <email@hidden>
  • Date: Wed, 29 Mar 2006 17:09:54 -0500

Thanks for the reply, I noticed the different return types too. I'll file a bug.

--
ivan

On Mar 29, 2006, at 3:32 PM, Nick Zitzmann wrote:


On Mar 29, 2006, at 1:22 PM, Ivan Kourtev wrote:

NSMutableCharacterSet inherits from NSCharacterSet which has a + characterSetWithCharactersInString method. Why then does the statement

NSMutableCharacterSet *cs = [NSMutableCharacterSet characterSetWithCharactersInString:@"#"];

produce an "initialization from distinct Objective-C type" warning?

I think you may have found a bug in Foundation. +[NSCharacterSet characterSetWithCharactersInString:] returns an object of type NSCharacterSet, whereas it really ought to return an object of type id. Since what you're trying to do above may not actually return a mutable character set (depending on how the method was implemented internally), you might want to try this instead:


NSMutableCharacterSet *cs = [[[NSCharacterSet characterSetWithCharactersInString:@"#"] mutableCopy] autorelease];

Please file a bug on this one...

By the same logic, I would expect

NSMutableString *s = [NSMutableString stringWithString:@"A"];

to generate a warning yet it does not.

What am I missing here?

+[NSMutableString stringWithString:@"A"] returns an object of type id.

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________ 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
References: 
 >confused about inheritance (From: Ivan Kourtev <email@hidden>)
 >Re: confused about inheritance (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Need of an Apple Engineer. Core-Data Issues
  • Next by Date: Re: Dragging promised files to finder behaviour question
  • Previous by thread: Re: confused about inheritance
  • Next by thread: "freed object" error
  • Index(es):
    • Date
    • Thread