fedor@boulder.colorado.edu
)rfm@gnu.org
)Version: 1.33
Date: 2005/02/22 11:22:44
Copyright: (C) 1993, 1994, 1996, 1999 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSValue.h
- Conforms to:
- NSCopying
- NSCoding
Standards:
- MacOS-X
- OpenStep
- GNUstep
Subclass of NSValue offering convenience methods for initializing from and accessing as any C primitive numeric type. On access, the value will be type-converted if necessary, using standard C conversion rules.
Method summaryNew instance from boolean value.
New instance from signed char value.
New instance from double value.
New instance from float value.
New instance from (signed) int value.
New instance from (signed) long value.
New instance from (signed) long long value.
New instance from (signed) short value.
New instance from unsigned char value.
New instance from unsigned int value.
New instance from unsigned long value.
New instance from unsigned long long value.
New instance from unsigned short value.
Return value as a BOOL; this will in fact be a char
value converted if necessary from type initialized
with; if you wish to consider anything nonzero TRUE
do not compare directly to YES
, but use
'!= NO'
.
Returns value as a signed char, converting if necessary.
Compares receiver with otherNumber,
using C type conversion if necessary, and returns
NSOrderedAscending
,
NSOrderedDescending
, or
NSOrderedSame
depending on whether it
is less than, greater than, or equal to
otherNumber.
Returns the string representation of this number using a non-localised conversion (decimal point is '.' irrespective of the locale).
Produces a string representation of the number. For a boolean this will be either 'true' or 'false'. For other numbers the format is produced using the initWithFormat:locale:... method of NSString, and the format depends on the type of number as follows -
Returns value as a double, converting if necessary.
Returns value as a float, converting if necessary.
Initialize from boolean value.
Initialize from signed char value.
Initialize from double value.
Initialize from float value.
Initialize from (signed) int value.
Initialize from (signed) long value.
Initialize from (signed) long long value.
Initialize from (signed) short value.
Initialize from unsigned char value.
Initialize from unsigned int value.
Initialize from unsigned long value.
Initialize from unsigned long long value.
Initialize from unsigned short value.
Returns value as a (signed) int, converting if necessary.
Returns whether receiver and otherNumber represent the same numerical value.
Returns value as a (signed) long long, converting if necessary.
Returns value as a (signed) long, converting if necessary.
Returns value as a (signed) short, converting if necessary.
Returns -description .
Returns value as an unsigned char, converting if necessary.
Returns value as an unsigned int, converting if necessary.
Returns value as an unsigned long long, converting if necessary.
Returns value as an unsigned long, converting if necessary.
Returns value as an unsigned short, converting if necessary.
- Declared in:
- Foundation/NSValue.h
- Conforms to:
- NSCopying
- NSCoding
Standards:
- MacOS-X
- OpenStep
- GNUstep
The NSValue
class can wrap a single
primitive value as an object so it can be used in
the containers and other places where an object reference
is needed. Once initialized, an NSValue
is
immutable, and there is no
NSMutableValue
class. You initialize it
by giving it a pointer to the primitive value, and you
should be careful this does not get freed until after
the NSValue
is no longer used.
Create new instance with specified value
(a pointer) of given type, which is a string
code obtainable through the compile-time operator
@encode(...)
. For example:
NSValue *theValue = [NSValue value: &n withObjCType: @encode(int)];
Synonym for value:withObjCType:.
Create new instance holding anObject. This is useful if you want to add anObject to a collection such as NSArray but don't want it to be retained (a weak reference).
Convenience method to create instance holding
an NSPoint
structure.
Convenience method to create instance holding a
pointer. Same as using
@encode(void *)
in
+value:withObjCType:
.
Convenience method to create instance holding
an NSRange
structure.
Convenience method to create instance holding
an NSRect
structure.
Convenience method to create instance holding
an NSSize
structure.
Copies bytes from the pointer receiver was initialized with into buffer pointed to by value. Number of bytes copied is determined by the type. If type was a void * pointer or object id, the memory address itself is copied.
Initialize with value of type, parallel to value:withObjCType:.
Compares this instance to another
NSValue
. For equality, both contents
and declared type of the two values must match.
If receiver was initialized with an object ID, return
it, else raises
NSInternalInconsistencyException
.
Returns the string @encode(...)
compatible type the receiver was initialized
with.
If receiver was initialized with an NSPoint
value, return it, else raises
NSInternalInconsistencyException
.
If receiver was initialized with a void * pointer,
return it, else raises
NSInternalInconsistencyException
.
If receiver was initialized with an NSRange
value, return it, else raises
NSInternalInconsistencyException
.
If receiver was initialized with an NSRect
value, return it, else raises
NSInternalInconsistencyException
.
If receiver was initialized with an NSSize
value, return it, else raises
NSInternalInconsistencyException
.
- Declared in:
- Foundation/NSValue.h
Standards:
- NotOpenStep
- NotMacOS-X
- GNUstep
GNUstep specific (non-standard) additions to the NSNumber class.
Method summary
Parses string as a double
,
int
, or unsigned int
depending on what characters are present. Uses
atof
and atoi
which don't
report errors, so be careful if the
string might contain an invalid value.
- Declared in:
- Foundation/NSValue.h
Standards:
- NotOpenStep
- NotMacOS-X
- GNUstep
Note: Defines a method that is not in the OpenStep spec, but makes subclassing easier.
Method summaryUsed by value: withObjCType: to determine the concrete subclass to alloc.