#[repr(C)]pub struct NSNumber(/* private fields */);Expand description
An object wrapper for primitive scalar numeric values.
There are static instances which make using certain numbers much faster.
See documentation.
Implementations§
Source§impl NSNumber
Scalar constructors.
impl NSNumber
Scalar constructors.
Sourcepub fn from_bool(value: bool) -> Arc<Self>
pub fn from_bool(value: bool) -> Arc<Self>
Creates a number object containing a boolean.
See documentation.
Sourcepub fn from_float(value: c_float) -> Arc<Self>
pub fn from_float(value: c_float) -> Arc<Self>
Creates a number object from a C float.
See documentation
Sourcepub fn from_double(value: c_double) -> Arc<Self>
pub fn from_double(value: c_double) -> Arc<Self>
Creates a number object from a C double.
See documentation
Sourcepub fn from_char(value: c_char) -> Arc<Self>
pub fn from_char(value: c_char) -> Arc<Self>
Creates a number object from a C char.
See documentation
Sourcepub fn from_short(value: c_short) -> Arc<Self>
pub fn from_short(value: c_short) -> Arc<Self>
Creates a number object from a C short.
See documentation
Sourcepub fn from_int(value: c_int) -> Arc<Self>
pub fn from_int(value: c_int) -> Arc<Self>
Creates a number object from a C int.
See documentation
Sourcepub fn from_long(value: c_long) -> Arc<Self>
pub fn from_long(value: c_long) -> Arc<Self>
Creates a number object from a C long.
See documentation
Sourcepub fn from_longlong(value: c_longlong) -> Arc<Self>
pub fn from_longlong(value: c_longlong) -> Arc<Self>
Creates a number object from a C long long.
See documentation
Sourcepub fn from_integer(value: NSInteger) -> Arc<Self>
pub fn from_integer(value: NSInteger) -> Arc<Self>
Creates a number object from an Objective-C integer.
See documentation
Sourcepub fn from_unsigned_char(value: c_uchar) -> Arc<Self>
pub fn from_unsigned_char(value: c_uchar) -> Arc<Self>
Creates a number object from a C unsigned char.
See documentation
Sourcepub fn from_unsigned_short(value: c_ushort) -> Arc<Self>
pub fn from_unsigned_short(value: c_ushort) -> Arc<Self>
Creates a number object from a C unsigned short.
See documentation
Sourcepub fn from_unsigned_int(value: c_uint) -> Arc<Self>
pub fn from_unsigned_int(value: c_uint) -> Arc<Self>
Creates a number object from a C unsigned int.
See documentation
Sourcepub fn from_unsigned_long(value: c_ulong) -> Arc<Self>
pub fn from_unsigned_long(value: c_ulong) -> Arc<Self>
Creates a number object from a C unsigned long.
See documentation
Sourcepub fn from_unsigned_longlong(value: c_ulonglong) -> Arc<Self>
pub fn from_unsigned_longlong(value: c_ulonglong) -> Arc<Self>
Creates a number object from a C unsigned long long.
See documentation
Sourcepub fn from_unsigned_integer(value: NSUInteger) -> Arc<Self>
pub fn from_unsigned_integer(value: NSUInteger) -> Arc<Self>
Creates a number object from a Objective-C unsigned integer.
See documentation
Source§impl NSNumber
Static instances.
impl NSNumber
Static instances.
Use these number references over corresponding constructors for better performance.
Sourcepub fn no() -> &'static NSNumber
pub fn no() -> &'static NSNumber
Returns a reference to the equivalent of @NO.
This internally references
kCFBooleanFalse.
Sourcepub fn yes() -> &'static NSNumber
pub fn yes() -> &'static NSNumber
Returns a reference to the equivalent of @YES.
This internally references
kCFBooleanTrue.
Sourcepub fn nan() -> &'static NSNumber
pub fn nan() -> &'static NSNumber
Returns a reference to a NaN (Not a Number) value.
This internally references
kCFNumberNaN.
Sourcepub fn infinity() -> &'static NSNumber
pub fn infinity() -> &'static NSNumber
Returns a reference to the infinity (∞) value.
This internally references
kCFNumberPositiveInfinity.
Sourcepub fn neg_infinity() -> &'static NSNumber
pub fn neg_infinity() -> &'static NSNumber
Returns a reference to the negative infinity (−∞) value.
This internally references
kCFNumberNegativeInfinity.
Source§impl NSNumber
Instance operations.
impl NSNumber
Instance operations.
Sourcepub fn compare(&self, other: &NSNumber) -> NSComparisonResult
pub fn compare(&self, other: &NSNumber) -> NSComparisonResult
Returns an NSComparisonResult value that indicates whether the number
object’s value is greater than, equal to, or less than a given number.
This method follows the standard C rules for type conversion. For example, if you compare an NSNumber object that has an integer value with an NSNumber object that has a floating point value, the integer value is converted to a floating-point value for comparison.
See documentation
Sourcepub fn string_value(&self) -> Arc<NSString<'static>>
pub fn string_value(&self) -> Arc<NSString<'static>>
Returns the number object’s value expressed as a human-readable string.
See documentation
Sourcepub fn description_with_locale<'l, L>(
&self,
locale: Option<&L>,
) -> Arc<NSString<'_>>where
L: AsRef<ObjCObject<'l>>,
pub fn description_with_locale<'l, L>(
&self,
locale: Option<&L>,
) -> Arc<NSString<'_>>where
L: AsRef<ObjCObject<'l>>,
Returns a string that represents the contents of the number object for a given locale.
See documentation
Source§impl NSNumber
Accessing numeric values.
impl NSNumber
Accessing numeric values.
Sourcepub fn bool_value(&self) -> bool
pub fn bool_value(&self) -> bool
Returns the number object’s value expressed as boolean, converted as necessary.
See documentation.
Sourcepub fn float_value(&self) -> c_float
pub fn float_value(&self) -> c_float
Returns the number object’s value expressed as a C float, converted as necessary.
See documentation.
Sourcepub fn double_value(&self) -> c_double
pub fn double_value(&self) -> c_double
Returns the number object’s value expressed as a C double, converted as necessary.
See documentation.
Sourcepub fn char_value(&self) -> c_char
pub fn char_value(&self) -> c_char
Returns the number object’s value expressed as a C char, converted as necessary.
See documentation.
Sourcepub fn short_value(&self) -> c_short
pub fn short_value(&self) -> c_short
Returns the number object’s value expressed as a C short, converted as necessary.
See documentation.
Sourcepub fn int_value(&self) -> c_int
pub fn int_value(&self) -> c_int
Returns the number object’s value expressed as a C int, converted as necessary.
See documentation.
Sourcepub fn long_value(&self) -> c_long
pub fn long_value(&self) -> c_long
Returns the number object’s value expressed as a C long, converted as necessary.
See documentation.
Sourcepub fn longlong_value(&self) -> c_longlong
pub fn longlong_value(&self) -> c_longlong
Returns the number object’s value expressed as a C long long, converted as necessary.
See documentation.
Sourcepub fn integer_value(&self) -> NSInteger
pub fn integer_value(&self) -> NSInteger
Returns the number object’s value expressed as an Objective-C integer, converted as necessary.
See documentation.
Sourcepub fn unsigned_char_value(&self) -> c_uchar
pub fn unsigned_char_value(&self) -> c_uchar
Returns the number object’s value expressed as a C unsigned char, converted as necessary.
See documentation.
Sourcepub fn unsigned_short_value(&self) -> c_ushort
pub fn unsigned_short_value(&self) -> c_ushort
Returns the number object’s value expressed as a C unsigned short, converted as necessary.
See documentation.
Sourcepub fn unsigned_int_value(&self) -> c_uint
pub fn unsigned_int_value(&self) -> c_uint
Returns the number object’s value expressed as a C unsigned int, converted as necessary.
See documentation.
Sourcepub fn unsigned_long_value(&self) -> c_ulong
pub fn unsigned_long_value(&self) -> c_ulong
Returns the number object’s value expressed as a C unsigned long, converted as necessary.
See documentation.
Sourcepub fn unsigned_longlong_value(&self) -> c_ulonglong
pub fn unsigned_longlong_value(&self) -> c_ulonglong
Returns the number object’s value expressed as a C unsigned long long, converted as necessary.
See documentation.
Sourcepub fn unsigned_integer_value(&self) -> NSUInteger
pub fn unsigned_integer_value(&self) -> NSUInteger
Returns the number object’s value expressed as an Objective-C unsigned integer, converted as necessary.
See documentation.
Methods from Deref<Target = NSValue>§
Sourcepub fn objc_type(&self) -> *const c_char
pub fn objc_type(&self) -> *const c_char
Returns a pointer to a C string containing the Objective-C type of this object’s value.
See documentation.
Sourcepub fn objc_type_cstr(&self) -> &CStr
pub fn objc_type_cstr(&self) -> &CStr
Returns objc_type as a C string reference.
Sourcepub unsafe fn write_value(&self, value: *mut c_void, size: NSUInteger)
pub unsafe fn write_value(&self, value: *mut c_void, size: NSUInteger)
Writes size bytes of the value to a pointer.
See documentation.
§Exception Handling
If size is the wrong number of bytes, an NSInvalidArgumentException
is thrown.
Sourcepub fn write_value_slice(&self, value: &mut [u8])
pub fn write_value_slice(&self, value: &mut [u8])
Writes the value to a slice buffer.
§Exception Handling
If value is the wrong number of bytes, an NSInvalidArgumentException
is thrown.
Sourcepub unsafe fn transmute_value<T>(&self) -> T
pub unsafe fn transmute_value<T>(&self) -> T
Sourcepub fn ptr_value(&self) -> *const c_void
pub fn ptr_value(&self) -> *const c_void
Returns the value as an untyped pointer.
The value as a pointer to void. If the value object was not created to hold a pointer-sized data item, the result is undefined.
See documentation.
Sourcepub fn nonretained_object_value(&self) -> *mut ObjCObject<'_>
pub fn nonretained_object_value(&self) -> *mut ObjCObject<'_>
Returns the value as a non-retained pointer to an object.
If the value was not created to hold a pointer-sized data item, the result is undefined.
See documentation.
Sourcepub fn range_value(&self) -> NSRange
pub fn range_value(&self) -> NSRange
Returns the value as an NSRange.
See documentation.
Sourcepub fn point_value(&self) -> NSPoint
pub fn point_value(&self) -> NSPoint
Returns the value as an NSPoint.
See documentation.
Sourcepub fn size_value(&self) -> NSSize
pub fn size_value(&self) -> NSSize
Returns the value as an NSSize.
See documentation.
Sourcepub fn rect_value(&self) -> NSRect
pub fn rect_value(&self) -> NSRect
Returns the value as an NSRect.
See documentation.
Sourcepub fn edge_insets_value(&self) -> NSEdgeInsets
pub fn edge_insets_value(&self) -> NSEdgeInsets
Returns the value as an NSEdgeInsets.
See documentation.
Methods from Deref<Target = NSObject<'static>>§
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Returns this object’s reference count.
This method is only useful for debugging certain objects.
See documentation.
Sourcepub fn responds_to_selector(&self, selector: Sel) -> bool
pub fn responds_to_selector(&self, selector: Sel) -> bool
Returns true if this object implements or inherits a method that can
respond to a specified message.
See documentation.
Sourcepub fn is_kind_of_class(&self, class: &Class) -> bool
pub fn is_kind_of_class(&self, class: &Class) -> bool
Returns true if this object is an instance or subclass of class.
See documentation
Sourcepub fn is_member_of_class(&self, class: &Class) -> bool
pub fn is_member_of_class(&self, class: &Class) -> bool
Returns true if this object is an instance of class.
See documentation
Sourcepub fn hash(&self) -> NSUInteger
pub fn hash(&self) -> NSUInteger
Returns an integer that can be used as a table address in a hash table structure.
See documentation.
Sourcepub fn copy(&self) -> Arc<Self>
pub fn copy(&self) -> Arc<Self>
Returns a copy of this object using
NSCopying.
See documentation.
Sourcepub fn mutable_copy(&self) -> Arc<Self>
pub fn mutable_copy(&self) -> Arc<Self>
Returns a copy of this object using
NSMutableCopying.
See documentation.
Sourcepub fn description(&self) -> Arc<NSString<'static>>
pub fn description(&self) -> Arc<NSString<'static>>
Returns a string that describes the contents of this object.
See documentation
Sourcepub fn debug_description(&self) -> Arc<NSString<'static>>
pub fn debug_description(&self) -> Arc<NSString<'static>>
Returns a string that describes the contents of the receiver for presentation in the debugger.
See documentation
Trait Implementations§
Source§impl ObjectType<'static> for NSNumber
impl ObjectType<'static> for NSNumber
Source§fn as_objc_object(&self) -> &ObjCObject<'data>
fn as_objc_object(&self) -> &ObjCObject<'data>
self into a type-erased Objective-C object.