Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling NSNumber class methods on NSDecimalNumber




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Calling NSNumber class methods on NSDecimalNumber (From: Dave Camp <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.