Class: NSValue
Overview
An NSValue object is a simple container for a single C or Objective-C data item. It can hold any of the scalar types such as int, float, and char, as well as pointers, structures, and object ids. The purpose of this class is to allow items of such data types to be added to collections such as instances of NSArray and NSSet, which require their elements to be objects. NSValue objects are always immutable.
Direct Known Subclasses
Class Method Summary (collapse)
-
+ value:withObjCType:
Creates and returns an NSValue object that contains a given value which is interpreted as being of a given Objective-C type.
-
+ valueWithBytes:objCType:
Creates and returns an NSValue object that contains a given value, which is interpreted as being of a given Objective-C type.
-
+ valueWithNonretainedObject:
Creates and returns an NSValue object that contains a given object.
-
+ valueWithPointer:
Creates and returns an NSValue object that contains a given pointer.
- + valueWithRange:
Instance Method Summary (collapse)
-
- getValue:
Copies the receiver’s value into a given buffer.
-
- initWithBytes:objCType:
Initializes and returns an NSValue object that contains a given value, which is interpreted as being of a given Objective-C type.
-
- isEqualToValue:
Returns a Boolean value that indicates whether the receiver and another value are equal.
-
- nonretainedObjectValue
Returns the receiver's value as an id.
-
- objCType
Returns a C string containing the Objective-C type of the data contained in the receiver.
-
- pointerValue
Returns the receiver's value as a pointer to void.
-
- rangeValue
Returns an NSRange structure representation of the receiver.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (NSValue) value(value, withObjCType:type)
Creates and returns an NSValue object that contains a given value which is interpreted as being of a given Objective-C type. This method has the same effect as valueWithBytes:objCType: and may be deprecated in a future release. You should use valueWithBytes:objCType: instead.
+ (NSValue) valueWithBytes(value, objCType:type)
+ (NSValue) valueWithNonretainedObject(anObject)
Creates and returns an NSValue object that contains a given object.
This method is equivalent to invoking value:withObjCType: in this manner:This method is useful if you want to add an object to a collection but don’t want the collection to create a strong reference to it.
+ (NSValue) valueWithPointer(aPointer)
Creates and returns an NSValue object that contains a given pointer. This method is equivalent to invoking value:withObjCType: in this manner:This method does not copy the contents of aPointer, so you must not to free the memory at the pointer destination while the NSValue object exists. NSData objects may be more suited for arbitrary pointers than NSValue objects.
Instance Method Details
- (Object) getValue(buffer)
Copies the receiver’s value into a given buffer.
- (Object) initWithBytes(value, objCType:type)
- (Boolean) isEqualToValue(value)
Returns a Boolean value that indicates whether the receiver and another value are equal.
- (Object) nonretainedObjectValue
Returns the receiver's value as an id.
- (const char) objCType
Returns a C string containing the Objective-C type of the data contained in the receiver.
- (Object) pointerValue
Returns the receiver's value as a pointer to void.