Struct cacao::foundation::NSNumber
source · [−]Expand description
Wrapper for a NSNumber
object.
In general we strive to avoid using this in the codebase, but it’s a requirement for moving
objects in and out of certain situations (e.g, UserDefaults
).
Tuple Fields
0: Id<Object>
Implementations
sourceimpl NSNumber
impl NSNumber
sourcepub fn retain(data: id) -> Self
pub fn retain(data: id) -> Self
If we’re vended an NSNumber from a method (e.g, NSUserDefaults
querying) we might want to
wrap (and retain) it while we figure out what to do with it. This does that.
sourcepub fn wrap(data: id) -> Self
pub fn wrap(data: id) -> Self
If we’re vended an NSNumber from a method (e.g, NSUserDefaults
querying) we might want to
wrap it while we figure out what to do with it. This does that.
sourcepub fn bool(value: bool) -> Self
pub fn bool(value: bool) -> Self
Constructs a numberWithBool
instance of NSNumber
and retains it.
sourcepub fn integer(value: i64) -> Self
pub fn integer(value: i64) -> Self
Constructs a numberWithInteger
instance of NSNumber
and retains it.
sourcepub fn float(value: f64) -> Self
pub fn float(value: f64) -> Self
Constructs a numberWithDouble
instance of NSNumber
and retains it.
sourcepub fn objc_type(&self) -> &str
pub fn objc_type(&self) -> &str
Returns the objCType
of the underlying NSNumber
as a Rust &str
. This flag can be used
to inform you how you should pull the underlying data out of the NSNumber
.
For more information: https://nshipster.com/type-encodings/
sourcepub fn as_i64(&self) -> i64
pub fn as_i64(&self) -> i64
Pulls the underlying NSInteger
value out and passes it back as an i64
.
Note that this does not check if the underlying type is actually this. You are
responsible for doing so via the objc_type()
method.
sourcepub fn as_f64(&self) -> f64
pub fn as_f64(&self) -> f64
Pulls the underlying double
value out and passes it back as an f64
.
Note that this does not check if the underlying type is actually this. You are
responsible for doing so via the objc_type()
method.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NSNumber
impl Send for NSNumber
impl Sync for NSNumber
impl Unpin for NSNumber
impl UnwindSafe for NSNumber
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more