Re: Calling NSNumber class methods on NSDecimalNumber
Re: Calling NSNumber class methods on NSDecimalNumber
- Subject: Re: Calling NSNumber class methods on NSDecimalNumber
- From: Jens Alfke <email@hidden>
- Date: Tue, 22 Apr 2008 09:09:51 -0700
On 22 Apr '08, at 8:19 AM, Dave Camp wrote:
The problem is that I get the warning "initialization from distinct
Objective-C type" when I do this, because the NSNumber class methods
return a specific type instead of id.
It's safe; you'll just need to cast the return value to
(NSDecimalNumber*) to avoid the warning.
I'm not sure I'd call this a bug in the headers. Most statically-typed
OOP language have this kind of problem handling methods that are
overridden to return a subclass instance. They could change the return
type to "id", as other classes like NSDictionary do, but then you lose
the type-checking. (There are several times I've accidentally assigned
[NSMutableArray array] to an NSSet*, for example, and wasted time
tracking down weird exceptions at runtime.)
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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