pub struct Exception(/* private fields */);
Expand description
An Objective-C exception.
While highly recommended that any exceptions you intend to throw are
subclasses of NSException
, this is not required by the runtime (similar
to how Rust can panic with arbitary payloads using panic_any
).
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: Encode>(&self, name: &str) -> &T
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T
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.
Trait Implementations§
source§impl Error for Exception
impl Error for Exception
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl RefEncode for Exception
impl RefEncode for Exception
source§const ENCODING_REF: Encoding = Encoding::Object
const ENCODING_REF: Encoding = Encoding::Object
The Objective-C type-encoding for a reference of this type. Read more
impl Message for Exception
impl RefUnwindSafe for Exception
impl UnwindSafe for Exception
Auto Trait Implementations§
impl !Freeze for Exception
impl !Send for Exception
impl !Sync for Exception
impl !Unpin for Exception
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more