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: Math operations for NSNumber




On May 31, 2007, at 5:31 PM, Ken Tozier wrote:

I know there are ways to extract C types from NSNumbers and numerous functions in Math.h for performing calculations but why doesn't NSNumber support calculations directly?

Because NSNumber is supposed to contain primitives in an array/ dictionary/set, not replace the primitives.


For example, say you have an NSArray of NSNumbers and you want to convert them in-place to their nth root. If NSNumber supported math functions, you could use NSArray's makeObjectsPerformSelector method to do it without having to loop through each, extract the value, get the root, and replace the number in the array.

There's nothing stopping you from writing your own method that does this, is there?


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


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Math operations for NSNumber (From: Ken Tozier <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.