Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights
Reserved.
NSNumber
Inherits From: NSValue : NSObject
Conforms To: NSCoding, NSCopying (NSValue)
NSObject (NSObject)
Declared In: Foundation/NSValue.h
Class Description
NSNumber objects provide an object-oriented wrapper for the standard C-language
number data types (int, double, etc.). The Foundation Kit's
collection classes can store only objects, so this class provides a way to
prepare numbers of various types for use with the collection classes.
NSNumber, which inherits from NSValue, provides methods for creating number
objects that contain data of a specified type. It also provides methods for
extracting data from a number object and casting the data to be of a particular
type. For determining whether two number objects are equal, NSNumber provides
the compare: method.
Allocating and Initializing
- + (NSNumber *)numberWithBool:(BOOL)value Creates and returns a
number object representing value of the type BOOL.
- + (NSNumber *)numberWithChar:(char)value Creates and returns a
number object representing value of the type char.
- + (NSNumber *)numberWithDouble:(double)value
Creates and returns a number object representing value of the
type double.
- + (NSNumber *)numberWithFloat:(float)value Creates and returns a
number object representing value of the type float.
- + (NSNumber *)numberWithInt:(int)value Creates and returns a
number object representing value of the type int.
- + (NSNumber *)numberWithLong:(long)value Creates and returns a
number object representing value of the type long.
- + (NSNumber *)numberWithLongLong:(long long)value
Creates and returns a number object representing value of the
type long long.
- + (NSNumber *)numberWithShort:(short)value Creates and returns a
number object representing value of the type short.
- + (NSNumber *)numberWithUnsignedChar:(unsigned char)value
Creates and returns a number object representing value of the
type unsigned char.
- + (NSNumber *)numberWithUnsignedInt:(unsigned int)value
Creates and returns a number object representing value of the
type unsigned int.
- + (NSNumber *)numberWithUnsignedLong:(unsigned long)value
Creates and returns a number object representing value of the
type unsigned long.
- + (NSNumber *)numberWithUnsignedLongLong:(unsigned long
long)value
Creates and returns a number object representing value of the
type unsigned long long.
- + (NSNumber *)numberWithUnsignedShort:(unsigned short)value
Creates and returns a number object representing value of the
type unsigned short.
Accessing Data
- - (BOOL)boolValue Returns the receiver's value as a boolean value.
- - (char)charValue Returns the receiver's value as a character value.
- - (double)doubleValue Returns the receiver's value as a double precision
floating point value.
- - (float)floatValue Returns the receiver's value as a single precision
floating point value.
- - (int)intValue Returns the receiver's value as a integer value.
- - (long long)longLongValue Returns the receiver's value as a long long
double precision floating point value.
- - (long)longValue Returns the receiver's value as a long double
precision floating point value.
- - (short)shortValue Returns the receiver's value as a short integer
value.
- - (NSString *)stringValue Returns the receiver's value as a string
contained in an NSString object.
- - (unsigned char)unsignedCharValue Returns the receiver's value as an
unsigned character value.
- - (unsigned int)unsignedIntValue Returns the receiver's value as an
unsigned integer value.
- - (unsigned long long)unsignedLongLongValue Returns the receiver's value
as an unsigned long long double precision floating point value.
- - (unsigned long)unsignedLongValue Returns the receiver's value as an
unsigned long double precision floating point value.
- - (unsigned short)unsignedShortValue Returns the receiver's value as an
unsigned short integer value.
Comparing Data
- - (NSComparisonResult)compare:(NSNumber *)otherNumber
Compares the receiver to otherNumber, using ANSI C rules for
type coersion, and returns an NSComparisonResult.