NSNumber

Struct NSNumber 

Source
#[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.

Source

pub fn from_bool(value: bool) -> Arc<Self>

Creates a number object containing a boolean.

See documentation.

Source

pub fn from_float(value: c_float) -> Arc<Self>

Creates a number object from a C float.

See documentation

Source

pub fn from_double(value: c_double) -> Arc<Self>

Creates a number object from a C double.

See documentation

Source

pub fn from_char(value: c_char) -> Arc<Self>

Creates a number object from a C char.

See documentation

Source

pub fn from_short(value: c_short) -> Arc<Self>

Creates a number object from a C short.

See documentation

Source

pub fn from_int(value: c_int) -> Arc<Self>

Creates a number object from a C int.

See documentation

Source

pub fn from_long(value: c_long) -> Arc<Self>

Creates a number object from a C long.

See documentation

Source

pub fn from_longlong(value: c_longlong) -> Arc<Self>

Creates a number object from a C long long.

See documentation

Source

pub fn from_integer(value: NSInteger) -> Arc<Self>

Creates a number object from an Objective-C integer.

See documentation

Source

pub fn from_unsigned_char(value: c_uchar) -> Arc<Self>

Creates a number object from a C unsigned char.

See documentation

Source

pub fn from_unsigned_short(value: c_ushort) -> Arc<Self>

Creates a number object from a C unsigned short.

See documentation

Source

pub fn from_unsigned_int(value: c_uint) -> Arc<Self>

Creates a number object from a C unsigned int.

See documentation

Source

pub fn from_unsigned_long(value: c_ulong) -> Arc<Self>

Creates a number object from a C unsigned long.

See documentation

Source

pub fn from_unsigned_longlong(value: c_ulonglong) -> Arc<Self>

Creates a number object from a C unsigned long long.

See documentation

Source

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.

Use these number references over corresponding constructors for better performance.

Source

pub fn no() -> &'static NSNumber

Returns a reference to the equivalent of @NO.

This internally references kCFBooleanFalse.

Source

pub fn yes() -> &'static NSNumber

Returns a reference to the equivalent of @YES.

This internally references kCFBooleanTrue.

Source

pub fn nan() -> &'static NSNumber

Returns a reference to a NaN (Not a Number) value.

This internally references kCFNumberNaN.

Source

pub fn infinity() -> &'static NSNumber

Returns a reference to the infinity (∞) value.

This internally references kCFNumberPositiveInfinity.

Source

pub fn neg_infinity() -> &'static NSNumber

Returns a reference to the negative infinity (−∞) value.

This internally references kCFNumberNegativeInfinity.

Source§

impl NSNumber

Instance operations.

Source

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

Source

pub fn string_value(&self) -> Arc<NSString<'static>>

Returns the number object’s value expressed as a human-readable string.

See documentation

Source

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.

Source

pub fn bool_value(&self) -> bool

Returns the number object’s value expressed as boolean, converted as necessary.

See documentation.

Source

pub fn float_value(&self) -> c_float

Returns the number object’s value expressed as a C float, converted as necessary.

See documentation.

Source

pub fn double_value(&self) -> c_double

Returns the number object’s value expressed as a C double, converted as necessary.

See documentation.

Source

pub fn char_value(&self) -> c_char

Returns the number object’s value expressed as a C char, converted as necessary.

See documentation.

Source

pub fn short_value(&self) -> c_short

Returns the number object’s value expressed as a C short, converted as necessary.

See documentation.

Source

pub fn int_value(&self) -> c_int

Returns the number object’s value expressed as a C int, converted as necessary.

See documentation.

Source

pub fn long_value(&self) -> c_long

Returns the number object’s value expressed as a C long, converted as necessary.

See documentation.

Source

pub fn longlong_value(&self) -> c_longlong

Returns the number object’s value expressed as a C long long, converted as necessary.

See documentation.

Source

pub fn integer_value(&self) -> NSInteger

Returns the number object’s value expressed as an Objective-C integer, converted as necessary.

See documentation.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>§

Source

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.

Source

pub fn objc_type_cstr(&self) -> &CStr

Returns objc_type as a C string reference.

Source

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.

Source

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.

Source

pub unsafe fn transmute_value<T>(&self) -> T

Returns the value as some generic type.

§Exception Handling

If the type is the wrong size, an NSInvalidArgumentException is thrown.

§Safety

The value must have a valid memory representation for the return type.

Source

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.

Source

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.

Source

pub fn range_value(&self) -> NSRange

Returns the value as an NSRange.

See documentation.

Source

pub fn point_value(&self) -> NSPoint

Returns the value as an NSPoint.

See documentation.

Source

pub fn size_value(&self) -> NSSize

Returns the value as an NSSize.

See documentation.

Source

pub fn rect_value(&self) -> NSRect

Returns the value as an NSRect.

See documentation.

Source

pub fn edge_insets_value(&self) -> NSEdgeInsets

Returns the value as an NSEdgeInsets.

See documentation.

Methods from Deref<Target = NSObject<'static>>§

Source

pub fn retain_count(&self) -> usize

Returns this object’s reference count.

This method is only useful for debugging certain objects.

See documentation.

Source

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.

Source

pub fn is_kind_of_class(&self, class: &Class) -> bool

Returns true if this object is an instance or subclass of class.

See documentation

Source

pub fn is_member_of_class(&self, class: &Class) -> bool

Returns true if this object is an instance of class.

See documentation

Source

pub fn hash(&self) -> NSUInteger

Returns an integer that can be used as a table address in a hash table structure.

See documentation.

Source

pub fn copy(&self) -> Arc<Self>

Returns a copy of this object using NSCopying.

See documentation.

Source

pub fn mutable_copy(&self) -> Arc<Self>

Returns a copy of this object using NSMutableCopying.

See documentation.

Source

pub fn description(&self) -> Arc<NSString<'static>>

Returns a string that describes the contents of this object.

See documentation

Source

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 AsMut<CFNumber> for NSNumber

Source§

fn as_mut(&mut self) -> &mut CFNumber

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<NSNumber> for CFNumber

Source§

fn as_mut(&mut self) -> &mut NSNumber

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<NSNumber> for NSNumber

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsMut<T> for NSNumber
where NSValue: AsMut<T>,

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<CFNumber> for NSNumber

Source§

fn as_ref(&self) -> &CFNumber

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSNumber> for CFBoolean

Source§

fn as_ref(&self) -> &NSNumber

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSNumber> for CFNumber

Source§

fn as_ref(&self) -> &NSNumber

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSNumber> for NSNumber

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> AsRef<T> for NSNumber
where NSValue: AsRef<T>,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ClassType<'static> for NSNumber

Source§

fn class() -> &'static Class

Returns the Objective-C class that can be used to instantiate a new instance of Self. Read more
Source§

impl Debug for NSNumber

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for NSNumber

Source§

type Target = NSValue

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for NSNumber

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&NSNumber> for Arc<NSString<'_>>

Source§

fn from(number: &NSNumber) -> Self

Converts to this type from the input type.
Source§

impl ObjectType<'static> for NSNumber

Source§

fn as_objc_object(&self) -> &ObjCObject<'data>

Casts self into a type-erased Objective-C object.
Source§

fn class<'s>(&'s self) -> &'s Class
where 'data: 's,

Returns the class that this object is an instance of.
Source§

impl ObjectType for NSNumber

Source§

fn retain(obj: &Self) -> Arc<Self>

Increments the object’s retain count and returns a smart pointer that automatically calls release on Drop. Read more
Source§

unsafe fn release(obj: NonNull<Self>)

Decrements the object’s retain count. Read more
Source§

impl Ord for NSNumber

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for NSNumber

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for NSNumber

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for NSNumber

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.