Re: confused about inheritance
Re: confused about inheritance
- Subject: Re: confused about inheritance
- From: Nick Zitzmann <email@hidden>
- Date: Wed, 29 Mar 2006 13:32:23 -0700
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