This is NSValue.rtf in view mode; [Download] [Up]
paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc. All Rights Reserved. s8 li100 fi0 ri1007 ql f0 b fs36 fs100 fs36 NSValue pard s18 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject fs20 fs28 s11 f0 b fs24 Conforms To:tab b0 fs28 f1 NSCoding, NSCopying fi0 NSObject (NSObject) fs20 fs28 s12 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSValue.h fi0 Foundation/NSGeometry.h fs20 fs28 pard s32 li100 fi0 ri1007 ql f0 b fs28 fs20 fs28 Class Description fs14 fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 NSValue objects provide an object-oriented wrapper for the data types defined in standard C and Objective C. The NSValue class is often used to put Objective C and standard C data types into collections that require objects, such as NSArray objects. When a value object is instantiated, it is encoded with the specified data type. fs16 fs28 The NSValue class declares the programmatic interface to an object that contains a C data type. It provides methods for creating value objects that contain values of a specified data type, pointers, and other objects. fs16 fs28 Use NSValue objects to put C types into collections. Use NSNumber objects to put numbers into collections. fs16 fs28 The following code puts an NSRange into an NSArray, using the Objective C b @encodeb0 directive to get a character string that encodes the type structure of NSRange: fs16 fs28 pard s9 li1231 fi0 ri1007 ql f2 fs20 [myArray insertObject:[NSValue value:&range withObjCType:@encode(NSRange)] atIndex:n] pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 fs28 To get the value back, you would do this: fs16 fs28 pard s9 li1231 fi0 ri1007 ql f2 fs20 [[myArray objectAtIndex:n] getValue:&range] pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 fs28 NSValue objects are provided with generic coding and copying behavior. To subclass NSValue and preserve class when encoding or copying, override b classForCoderb0 , b initWithCoder:,b0 b encodeWithCoder:b0 (for encoding), and b copyWithZone:b0 (for copying). fs16 fs28 pard s32 li100 fi0 ri1007 ql f0 b fs24 fs28 General Exception Conditions fs14 fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 NSValue can raise NSInternalInconsistencyException in a variety of cases where an unkown Objective C type is found. In addition, NSValue'27s implementation of b encodeWithCoder:b0 can raise NSInvalidArgumentException if an attempt is made to encode b voidb0 . fs16 fs28 pard s32 li100 fi0 ri1007 ql f0 b fs24 fs28 Allocating and Initializing Value Objects fs14 fs28 pard s13 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (NSValue *)b value:b0 (const void *)i valuei0 tab Creates and returns a value object containing the value s14 li7030 fi-6553 fi-5796 b withObjCType:b0 (const char *)i typei0 tab i tab valuei0 of the Objective C type i typei0 . s13 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 + (NSValue *)b valueWithNonretainedObject:b0 (id)i anObject s14 li7030 fi-6553 fi-5796 i0 tab Creates and returns a value object containing the object i anObject,i0 without retaining i anObjecti0 . fs28 This is provided as a convenience method: the statement fs28 [NSValue valueWithNonretainedOject:i anObjecti0 ] is equivalent to the statement [NSValue value:&i anObjecti0 withObjCType:@encode(void *)]. s13 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 + (NSValue *)b valueWithPointer:b0 (const void *)i pointer s14 li7030 fi-6553 fi-5796 i0 tab Creates and returns a value object that contains the specified pointer.fs28 This is provided as a convenience method: the statement fs28 [NSValue valueWithPointer:i pointeri0 ] is equivalent to the statement [NSValue value:&i pointeri0 withObjCType:@encode(void *)]. pard s32 li100 fi0 ri1007 ql f0 b fs48 fs28 Allocating and Initializing Geometry Value Objects fs14 fs28 pard s13 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (NSValue *)b valueWithPoint:b0 (NSPoint)i pointtab i0 Creates and returns a value object that contains the specifiedi i0 NSPoint structure (which represents a geometrical point in two dimensions). fi-6552 fs16 fs28 fi-6552 + (NSValue *)b valueWithRect:b0 (NSRect)i recttab i0 Creates and returns a value object that contains the specifiedi i0 NSRect structure, representing a rectangle. fi-6552 fs16 fs28 fi-6552 + (NSValue *)b valueWithSize:b0 (NSSize)i sizei0 tab Creates and returns a value object that contains the specifiedi i0 NSSize structure (which stores a width and a height). pard s32 li100 fi0 ri1007 ql f0 b fs48 fs28 Accessing Data in Value Objects fs14 fs28 pard s13 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b getValue:b0 (void *)i valuei0 tab Copies the receiver'27s data into i valuei0 . fi-6552 fs16 fs28 fi-6552 {f3 -} (id)b nonretainedObjectValueb0 tab Returns the non-retained object that'27s contained in the receiver. It'27s an error to send this message to an NSValue object that doesn'27t store a nonretained object. fi-6552 fs16 fs28 fi-6552 {f3 -} (const char *)b objCTypeb0 tab Returns the Objective C type of the data contained in the receiver. fi-6552 fs16 fs28 fi-6552 {f3 -} (void *)b pointerValueb0 tab Returns the value pointed to by a pointer contained in an value object. It'27s an error to send this message to an NSValue that doesn'27t store a pointer. pard s32 li100 fi0 ri1007 ql f0 b fs48 fs28 Accessing Data in Value Geometry Objects fs14 fs28 pard s13 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (NSPoint)b pointValueb0 tab Returns the point structure that'27s contained in the receiver. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSRect)b rectValueb0 tab Returns the rectangle structure that'27s contained in the receiver. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSSize)b sizeValuetab b0 Returns the size structure that'27s contained in the receiverb . fi-6552 b0 fs16 fs28 fi-6552 }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.