O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSValue — Mac OS X 10.0

Synopsis

This class provides an object-oriented interface to C and Objective-C scalar data items, such as numeric primitives, and C structures. Providing an object-oriented wrapper for these non-object types makes it possible for clients to store these types in any of the Foundation collection classes.

image with no caption

@interface NSValue : NSObject <NSCoding, NSCopying>
                                  // Convenience Constructors
   + (NSValue *)value:(const void *)value 
                                 withObjCType:(const char *)type;
   + (NSValue *)valueWithBytes:(const void *)value 
                                 objCType:(const char *)type;
   + (NSValue *)valueWithNonretainedObject:(id)anObject;
   + (NSValue *)valueWithPoint:(NSPoint)point;
   + (NSValue *)valueWithPointer:(const void *)pointer;
   + (NSValue *)valueWithRange:(NSRange)range;
   + (NSValue *)valueWithRect:(NSRect)rect;
   + (NSValue *)valueWithSize:(NSSize)size;
                                  // Initializers
   - (id)initWithBytes:(const void *)value 
                                 objCType:(const char *)type;
                                  // Instance Methods
   - (void)getValue:(void *)value;
   - (BOOL)isEqualToValue:(NSValue *)value;
   - (id)nonretainedObjectValue;
   - (const char *)objCType;
   - (NSPoint)pointValue;
   - (void *)pointerValue;
   - (NSRange)rangeValue;
   - (NSRect)rectValue;
   - (NSSize)sizeValue;
                                  // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
                                  // Methods Implementing NSCopying
   - (id)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required