• 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: Calling NSNumber class methods on NSDecimalNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

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

  • Prev by Date: Re: Programmatically placing an item in the dock
  • Next by Date: Re: Programmatically placing an item in the dock
  • Previous by thread: Calling NSNumber class methods on NSDecimalNumber
  • Next by thread: NSButton "reveals" keyboard shortuct
  • Index(es):
    • Date
    • Thread