#[repr(C)]pub struct NSValue { /* private fields */ }icrate::Foundation has been moved to objc2-foundationFoundation and Foundation_NSValue only.Implementations§
Source§impl NSValue
Creation methods.
impl NSValue
Creation methods.
Sourcepub fn new<T: 'static + Copy + Encode>(value: T) -> Id<Self>
👎Deprecated: icrate::Foundation has been moved to objc2-foundation
pub fn new<T: 'static + Copy + Encode>(value: T) -> Id<Self>
icrate::Foundation has been moved to objc2-foundationCreate a new NSValue containing the given type.
Be careful when using this since you may accidentally pass a reference when you wanted to pass a concrete type instead.
§Examples
Create an NSValue containing an NSPoint.
use icrate::Foundation::{NSPoint, NSValue};
let val = NSValue::new::<NSPoint>(NSPoint::new(1.0, 1.0));Source§impl NSValue
Getter methods.
impl NSValue
Getter methods.
Sourcepub unsafe fn get<T: 'static + Copy + Encode>(&self) -> T
👎Deprecated: icrate::Foundation has been moved to objc2-foundation
pub unsafe fn get<T: 'static + Copy + Encode>(&self) -> T
icrate::Foundation has been moved to objc2-foundationRetrieve the data contained in the NSValue.
Note that this is broken on GNUStep for some types, see gnustep/libs-base#216.
§Safety
The type of T must be what the NSValue actually stores, and any
safety invariants that the value has must be upheld.
Note that it may be enough, although is not always, to check whether
contains_encoding returns true. For example, NonNull<T> have
the same encoding as *const T, but NonNull<T> is clearly not
safe to return from this function even if you’ve checked the encoding
beforehand.
§Examples
Store a pointer in NSValue, and retrieve it again afterwards.
use std::ffi::c_void;
use std::ptr;
use icrate::Foundation::NSValue;
let val = NSValue::new::<*const c_void>(ptr::null());
// SAFETY: The value was just created with a pointer
let res = unsafe { val.get::<*const c_void>() };
assert!(res.is_null());pub fn get_range(&self) -> Option<NSRange>
icrate::Foundation has been moved to objc2-foundationpub fn get_point(&self) -> Option<NSPoint>
icrate::Foundation has been moved to objc2-foundationpub fn get_size(&self) -> Option<NSSize>
icrate::Foundation has been moved to objc2-foundationpub fn get_rect(&self) -> Option<NSRect>
icrate::Foundation has been moved to objc2-foundationpub fn encoding(&self) -> Option<&str>
icrate::Foundation has been moved to objc2-foundationpub fn contains_encoding<T: 'static + Copy + Encode>(&self) -> bool
icrate::Foundation has been moved to objc2-foundationSource§impl NSValue
NSValueGeometryExtensions
impl NSValue
NSValueGeometryExtensions
pub unsafe fn valueWithPoint(point: NSPoint) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn valueWithSize(size: NSSize) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn valueWithRect(rect: NSRect) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn valueWithEdgeInsets(insets: NSEdgeInsets) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn pointValue(&self) -> NSPoint
icrate::Foundation has been moved to objc2-foundationpub unsafe fn sizeValue(&self) -> NSSize
icrate::Foundation has been moved to objc2-foundationpub unsafe fn rectValue(&self) -> NSRect
icrate::Foundation has been moved to objc2-foundationpub unsafe fn edgeInsetsValue(&self) -> NSEdgeInsets
icrate::Foundation has been moved to objc2-foundationSource§impl NSValue
NSValueRangeExtensions
impl NSValue
NSValueRangeExtensions
pub unsafe fn valueWithRange(range: NSRange) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn rangeValue(&self) -> NSRange
icrate::Foundation has been moved to objc2-foundationSource§impl NSValue
impl NSValue
pub unsafe fn getValue_size(&self, value: NonNull<c_void>, size: NSUInteger)
icrate::Foundation has been moved to objc2-foundationpub fn objCType(&self) -> NonNull<c_char>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn initWithBytes_objCType( this: Allocated<Self>, value: NonNull<c_void>, type: NonNull<c_char>, ) -> Id<Self>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Id<Self>>
icrate::Foundation has been moved to objc2-foundationFoundation_NSCoder only.Source§impl NSValue
NSValueCreation
impl NSValue
NSValueCreation
pub unsafe fn valueWithBytes_objCType( value: NonNull<c_void>, type: NonNull<c_char>, ) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn value_withObjCType( value: NonNull<c_void>, type: NonNull<c_char>, ) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationSource§impl NSValue
NSValueExtensionMethods
impl NSValue
NSValueExtensionMethods
pub unsafe fn valueWithNonretainedObject( an_object: Option<&AnyObject>, ) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn nonretainedObjectValue(&self) -> Option<Id<AnyObject>>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn valueWithPointer(pointer: *mut c_void) -> Id<NSValue>
icrate::Foundation has been moved to objc2-foundationpub unsafe fn pointerValue(&self) -> *mut c_void
icrate::Foundation has been moved to objc2-foundationpub fn isEqualToValue(&self, value: &NSValue) -> bool
icrate::Foundation has been moved to objc2-foundationSource§impl NSValue
NSValueMapKitGeometryExtensions
impl NSValue
NSValueMapKitGeometryExtensions
pub unsafe fn valueWithMKCoordinate( coordinate: CLLocationCoordinate2D, ) -> Id<NSValue>
icrate::MapKit has been moved to objc2-map-kitMapKit only.pub unsafe fn valueWithMKCoordinateSpan(span: MKCoordinateSpan) -> Id<NSValue>
icrate::MapKit has been moved to objc2-map-kitMapKit only.pub unsafe fn MKCoordinateValue(&self) -> CLLocationCoordinate2D
icrate::MapKit has been moved to objc2-map-kitMapKit only.pub unsafe fn MKCoordinateSpanValue(&self) -> MKCoordinateSpan
icrate::MapKit has been moved to objc2-map-kitMapKit only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Available on crate feature AuthenticationServices only.
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
AuthenticationServices only.Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load_mut instead.
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
Ivar::load_mut instead.Use Ivar::load_mut instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Trait Implementations§
Source§impl AsMut<NSValue> for NSDecimalNumber
impl AsMut<NSValue> for NSDecimalNumber
Source§impl AsRef<NSValue> for NSDecimalNumber
impl AsRef<NSValue> for NSDecimalNumber
Source§impl Borrow<NSValue> for NSDecimalNumber
impl Borrow<NSValue> for NSDecimalNumber
Source§impl BorrowMut<AnyObject> for NSValue
impl BorrowMut<AnyObject> for NSValue
Source§fn borrow_mut(&mut self) -> &mut AnyObject
fn borrow_mut(&mut self) -> &mut AnyObject
Source§impl BorrowMut<NSObject> for NSValue
impl BorrowMut<NSObject> for NSValue
Source§fn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
Source§impl BorrowMut<NSValue> for NSDecimalNumber
impl BorrowMut<NSValue> for NSDecimalNumber
Source§fn borrow_mut(&mut self) -> &mut NSValue
fn borrow_mut(&mut self) -> &mut NSValue
Source§impl BorrowMut<NSValue> for NSNumber
impl BorrowMut<NSValue> for NSNumber
Source§fn borrow_mut(&mut self) -> &mut NSValue
fn borrow_mut(&mut self) -> &mut NSValue
Source§impl ClassType for NSValue
impl ClassType for NSValue
Source§const NAME: &'static str = "NSValue"
const NAME: &'static str = "NSValue"
Source§type Mutability = Immutable
type Mutability = Immutable
Source§fn class() -> &'static AnyClass
fn class() -> &'static AnyClass
Source§fn as_super_mut(&mut self) -> &mut Self::Super
fn as_super_mut(&mut self) -> &mut Self::Super
Source§impl NSCoding for NSValue
impl NSCoding for NSValue
Source§unsafe fn encodeWithCoder(&self, coder: &NSCoder)
unsafe fn encodeWithCoder(&self, coder: &NSCoder)
icrate::Foundation has been moved to objc2-foundationFoundation_NSCoder only.