pub struct CATransformLayer { /* private fields */ }
CALayer
and CATransformLayer
only.Expand description
Implementations§
Source§impl CATransformLayer
Methods declared on superclass CALayer
.
impl CATransformLayer
Methods declared on superclass CALayer
.
Methods from Deref<Target = CALayer>§
pub fn constraints(&self) -> Option<Retained<NSArray<CAConstraint>>>
CAConstraintLayoutManager
only.Sourcepub fn setConstraints(&self, constraints: Option<&NSArray<CAConstraint>>)
Available on crate feature CAConstraintLayoutManager
only.
pub fn setConstraints(&self, constraints: Option<&NSArray<CAConstraint>>)
CAConstraintLayoutManager
only.Setter for constraints
.
This is copied when set.
pub fn addConstraint(&self, c: &CAConstraint)
CAConstraintLayoutManager
only.pub unsafe fn presentationLayer(&self) -> Option<Retained<Self>>
pub unsafe fn modelLayer(&self) -> Retained<Self>
pub fn shouldArchiveValueForKey(&self, key: &NSString) -> bool
Sourcepub fn bounds(&self) -> CGRect
Available on crate feature objc2-core-foundation
only.
pub fn bounds(&self) -> CGRect
objc2-core-foundation
only.Geometry and layer hierarchy properties. *
Sourcepub fn setBounds(&self, bounds: CGRect)
Available on crate feature objc2-core-foundation
only.
pub fn setBounds(&self, bounds: CGRect)
objc2-core-foundation
only.Setter for bounds
.
pub fn position(&self) -> CGPoint
objc2-core-foundation
only.Sourcepub fn setPosition(&self, position: CGPoint)
Available on crate feature objc2-core-foundation
only.
pub fn setPosition(&self, position: CGPoint)
objc2-core-foundation
only.Setter for position
.
pub fn zPosition(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setZPosition(&self, z_position: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setZPosition(&self, z_position: CGFloat)
objc2-core-foundation
only.Setter for zPosition
.
pub fn anchorPoint(&self) -> CGPoint
objc2-core-foundation
only.Sourcepub fn setAnchorPoint(&self, anchor_point: CGPoint)
Available on crate feature objc2-core-foundation
only.
pub fn setAnchorPoint(&self, anchor_point: CGPoint)
objc2-core-foundation
only.Setter for anchorPoint
.
pub fn anchorPointZ(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setAnchorPointZ(&self, anchor_point_z: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setAnchorPointZ(&self, anchor_point_z: CGFloat)
objc2-core-foundation
only.Setter for anchorPointZ
.
pub fn transform(&self) -> CATransform3D
CATransform3D
and objc2-core-foundation
only.Sourcepub fn setTransform(&self, transform: CATransform3D)
Available on crate features CATransform3D
and objc2-core-foundation
only.
pub fn setTransform(&self, transform: CATransform3D)
CATransform3D
and objc2-core-foundation
only.Setter for transform
.
pub fn affineTransform(&self) -> CGAffineTransform
objc2-core-foundation
only.pub fn setAffineTransform(&self, m: CGAffineTransform)
objc2-core-foundation
only.pub fn frame(&self) -> CGRect
objc2-core-foundation
only.Sourcepub fn setFrame(&self, frame: CGRect)
Available on crate feature objc2-core-foundation
only.
pub fn setFrame(&self, frame: CGRect)
objc2-core-foundation
only.Setter for frame
.
pub fn isHidden(&self) -> bool
pub fn isDoubleSided(&self) -> bool
Sourcepub fn setDoubleSided(&self, double_sided: bool)
pub fn setDoubleSided(&self, double_sided: bool)
Setter for isDoubleSided
.
pub fn isGeometryFlipped(&self) -> bool
Sourcepub fn setGeometryFlipped(&self, geometry_flipped: bool)
pub fn setGeometryFlipped(&self, geometry_flipped: bool)
Setter for isGeometryFlipped
.
pub fn contentsAreFlipped(&self) -> bool
pub fn superlayer(&self) -> Option<Retained<CALayer>>
pub fn removeFromSuperlayer(&self)
pub unsafe fn sublayers(&self) -> Option<Retained<NSArray<CALayer>>>
Sourcepub unsafe fn setSublayers(&self, sublayers: Option<&NSArray<CALayer>>)
pub unsafe fn setSublayers(&self, sublayers: Option<&NSArray<CALayer>>)
pub fn addSublayer(&self, layer: &CALayer)
pub fn insertSublayer_atIndex(&self, layer: &CALayer, idx: c_uint)
pub fn insertSublayer_below(&self, layer: &CALayer, sibling: Option<&CALayer>)
pub fn insertSublayer_above(&self, layer: &CALayer, sibling: Option<&CALayer>)
pub unsafe fn replaceSublayer_with( &self, old_layer: &CALayer, new_layer: &CALayer, )
pub fn sublayerTransform(&self) -> CATransform3D
CATransform3D
and objc2-core-foundation
only.Sourcepub fn setSublayerTransform(&self, sublayer_transform: CATransform3D)
Available on crate features CATransform3D
and objc2-core-foundation
only.
pub fn setSublayerTransform(&self, sublayer_transform: CATransform3D)
CATransform3D
and objc2-core-foundation
only.Setter for sublayerTransform
.
pub fn mask(&self) -> Option<Retained<CALayer>>
pub fn masksToBounds(&self) -> bool
Sourcepub fn setMasksToBounds(&self, masks_to_bounds: bool)
pub fn setMasksToBounds(&self, masks_to_bounds: bool)
Setter for masksToBounds
.
Sourcepub fn convertPoint_fromLayer(&self, p: CGPoint, l: Option<&CALayer>) -> CGPoint
Available on crate feature objc2-core-foundation
only.
pub fn convertPoint_fromLayer(&self, p: CGPoint, l: Option<&CALayer>) -> CGPoint
objc2-core-foundation
only.Mapping between layer coordinate and time spaces. *
pub fn convertPoint_toLayer(&self, p: CGPoint, l: Option<&CALayer>) -> CGPoint
objc2-core-foundation
only.pub fn convertRect_fromLayer(&self, r: CGRect, l: Option<&CALayer>) -> CGRect
objc2-core-foundation
only.pub fn convertRect_toLayer(&self, r: CGRect, l: Option<&CALayer>) -> CGRect
objc2-core-foundation
only.pub fn convertTime_fromLayer( &self, t: CFTimeInterval, l: Option<&CALayer>, ) -> CFTimeInterval
objc2-core-foundation
only.pub fn convertTime_toLayer( &self, t: CFTimeInterval, l: Option<&CALayer>, ) -> CFTimeInterval
objc2-core-foundation
only.Sourcepub fn hitTest(&self, p: CGPoint) -> Option<Retained<CALayer>>
Available on crate feature objc2-core-foundation
only.
pub fn hitTest(&self, p: CGPoint) -> Option<Retained<CALayer>>
objc2-core-foundation
only.Hit testing methods. *
pub fn containsPoint(&self, p: CGPoint) -> bool
objc2-core-foundation
only.Sourcepub unsafe fn contents(&self) -> Option<Retained<AnyObject>>
pub unsafe fn contents(&self) -> Option<Retained<AnyObject>>
Layer content properties and methods. *
Sourcepub unsafe fn setContents(&self, contents: Option<&AnyObject>)
pub unsafe fn setContents(&self, contents: Option<&AnyObject>)
pub fn contentsRect(&self) -> CGRect
objc2-core-foundation
only.Sourcepub fn setContentsRect(&self, contents_rect: CGRect)
Available on crate feature objc2-core-foundation
only.
pub fn setContentsRect(&self, contents_rect: CGRect)
objc2-core-foundation
only.Setter for contentsRect
.
pub fn contentsGravity(&self) -> Retained<CALayerContentsGravity>
Sourcepub fn setContentsGravity(&self, contents_gravity: &CALayerContentsGravity)
pub fn setContentsGravity(&self, contents_gravity: &CALayerContentsGravity)
Setter for contentsGravity
.
This is copied when set.
pub fn contentsScale(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setContentsScale(&self, contents_scale: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setContentsScale(&self, contents_scale: CGFloat)
objc2-core-foundation
only.Setter for contentsScale
.
pub fn contentsCenter(&self) -> CGRect
objc2-core-foundation
only.Sourcepub fn setContentsCenter(&self, contents_center: CGRect)
Available on crate feature objc2-core-foundation
only.
pub fn setContentsCenter(&self, contents_center: CGRect)
objc2-core-foundation
only.Setter for contentsCenter
.
pub fn contentsFormat(&self) -> Retained<CALayerContentsFormat>
Sourcepub fn setContentsFormat(&self, contents_format: &CALayerContentsFormat)
pub fn setContentsFormat(&self, contents_format: &CALayerContentsFormat)
Setter for contentsFormat
.
This is copied when set.
pub fn wantsExtendedDynamicRangeContent(&self) -> bool
Sourcepub fn setWantsExtendedDynamicRangeContent(
&self,
wants_extended_dynamic_range_content: bool,
)
👎Deprecated: Use preferredDynamicRange instead
pub fn setWantsExtendedDynamicRangeContent( &self, wants_extended_dynamic_range_content: bool, )
Setter for wantsExtendedDynamicRangeContent
.
pub fn toneMapMode(&self) -> Retained<CAToneMapMode>
Sourcepub fn setToneMapMode(&self, tone_map_mode: &CAToneMapMode)
pub fn setToneMapMode(&self, tone_map_mode: &CAToneMapMode)
Setter for toneMapMode
.
This is copied when set.
pub fn preferredDynamicRange(&self) -> Retained<CADynamicRange>
Sourcepub fn setPreferredDynamicRange(&self, preferred_dynamic_range: &CADynamicRange)
pub fn setPreferredDynamicRange(&self, preferred_dynamic_range: &CADynamicRange)
Setter for preferredDynamicRange
.
This is copied when set.
pub fn contentsHeadroom(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setContentsHeadroom(&self, contents_headroom: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setContentsHeadroom(&self, contents_headroom: CGFloat)
objc2-core-foundation
only.Setter for contentsHeadroom
.
pub fn wantsDynamicContentScaling(&self) -> bool
Sourcepub fn setWantsDynamicContentScaling(&self, wants_dynamic_content_scaling: bool)
pub fn setWantsDynamicContentScaling(&self, wants_dynamic_content_scaling: bool)
Setter for wantsDynamicContentScaling
.
pub fn minificationFilter(&self) -> Retained<CALayerContentsFilter>
Sourcepub fn setMinificationFilter(&self, minification_filter: &CALayerContentsFilter)
pub fn setMinificationFilter(&self, minification_filter: &CALayerContentsFilter)
Setter for minificationFilter
.
This is copied when set.
pub fn magnificationFilter(&self) -> Retained<CALayerContentsFilter>
Sourcepub fn setMagnificationFilter(
&self,
magnification_filter: &CALayerContentsFilter,
)
pub fn setMagnificationFilter( &self, magnification_filter: &CALayerContentsFilter, )
Setter for magnificationFilter
.
This is copied when set.
pub fn minificationFilterBias(&self) -> c_float
Sourcepub fn setMinificationFilterBias(&self, minification_filter_bias: c_float)
pub fn setMinificationFilterBias(&self, minification_filter_bias: c_float)
Setter for minificationFilterBias
.
pub fn isOpaque(&self) -> bool
pub fn display(&self)
pub fn setNeedsDisplay(&self)
pub fn setNeedsDisplayInRect(&self, r: CGRect)
objc2-core-foundation
only.pub fn needsDisplay(&self) -> bool
pub fn displayIfNeeded(&self)
pub fn needsDisplayOnBoundsChange(&self) -> bool
Sourcepub fn setNeedsDisplayOnBoundsChange(
&self,
needs_display_on_bounds_change: bool,
)
pub fn setNeedsDisplayOnBoundsChange( &self, needs_display_on_bounds_change: bool, )
Setter for needsDisplayOnBoundsChange
.
pub fn drawsAsynchronously(&self) -> bool
Sourcepub fn setDrawsAsynchronously(&self, draws_asynchronously: bool)
pub fn setDrawsAsynchronously(&self, draws_asynchronously: bool)
Setter for drawsAsynchronously
.
pub fn drawInContext(&self, ctx: &CGContext)
objc2-core-graphics
only.Sourcepub fn renderInContext(&self, ctx: &CGContext)
Available on crate feature objc2-core-graphics
only.
pub fn renderInContext(&self, ctx: &CGContext)
objc2-core-graphics
only.Rendering properties and methods. *
pub fn edgeAntialiasingMask(&self) -> CAEdgeAntialiasingMask
Sourcepub fn setEdgeAntialiasingMask(
&self,
edge_antialiasing_mask: CAEdgeAntialiasingMask,
)
pub fn setEdgeAntialiasingMask( &self, edge_antialiasing_mask: CAEdgeAntialiasingMask, )
Setter for edgeAntialiasingMask
.
pub fn allowsEdgeAntialiasing(&self) -> bool
Sourcepub fn setAllowsEdgeAntialiasing(&self, allows_edge_antialiasing: bool)
pub fn setAllowsEdgeAntialiasing(&self, allows_edge_antialiasing: bool)
Setter for allowsEdgeAntialiasing
.
pub fn backgroundColor(&self) -> Option<Retained<CGColor>>
objc2-core-graphics
only.Sourcepub fn setBackgroundColor(&self, background_color: Option<&CGColor>)
Available on crate feature objc2-core-graphics
only.
pub fn setBackgroundColor(&self, background_color: Option<&CGColor>)
objc2-core-graphics
only.Setter for backgroundColor
.
pub fn cornerRadius(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setCornerRadius(&self, corner_radius: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setCornerRadius(&self, corner_radius: CGFloat)
objc2-core-foundation
only.Setter for cornerRadius
.
pub fn maskedCorners(&self) -> CACornerMask
Sourcepub fn setMaskedCorners(&self, masked_corners: CACornerMask)
pub fn setMaskedCorners(&self, masked_corners: CACornerMask)
Setter for maskedCorners
.
pub fn cornerCurve(&self) -> Retained<CALayerCornerCurve>
Sourcepub fn setCornerCurve(&self, corner_curve: &CALayerCornerCurve)
pub fn setCornerCurve(&self, corner_curve: &CALayerCornerCurve)
Setter for cornerCurve
.
This is copied when set.
pub fn borderWidth(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setBorderWidth(&self, border_width: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setBorderWidth(&self, border_width: CGFloat)
objc2-core-foundation
only.Setter for borderWidth
.
pub fn borderColor(&self) -> Option<Retained<CGColor>>
objc2-core-graphics
only.Sourcepub fn setBorderColor(&self, border_color: Option<&CGColor>)
Available on crate feature objc2-core-graphics
only.
pub fn setBorderColor(&self, border_color: Option<&CGColor>)
objc2-core-graphics
only.Setter for borderColor
.
pub fn opacity(&self) -> c_float
Sourcepub fn setOpacity(&self, opacity: c_float)
pub fn setOpacity(&self, opacity: c_float)
Setter for opacity
.
pub fn allowsGroupOpacity(&self) -> bool
Sourcepub fn setAllowsGroupOpacity(&self, allows_group_opacity: bool)
pub fn setAllowsGroupOpacity(&self, allows_group_opacity: bool)
Setter for allowsGroupOpacity
.
pub fn compositingFilter(&self) -> Option<Retained<AnyObject>>
Sourcepub unsafe fn setCompositingFilter(
&self,
compositing_filter: Option<&AnyObject>,
)
pub unsafe fn setCompositingFilter( &self, compositing_filter: Option<&AnyObject>, )
pub fn filters(&self) -> Option<Retained<NSArray>>
Sourcepub unsafe fn setFilters(&self, filters: Option<&NSArray>)
pub unsafe fn setFilters(&self, filters: Option<&NSArray>)
pub fn backgroundFilters(&self) -> Option<Retained<NSArray>>
Sourcepub unsafe fn setBackgroundFilters(&self, background_filters: Option<&NSArray>)
pub unsafe fn setBackgroundFilters(&self, background_filters: Option<&NSArray>)
Setter for backgroundFilters
.
This is copied when set.
§Safety
background_filters
generic should be of the correct type.
pub fn shouldRasterize(&self) -> bool
Sourcepub fn setShouldRasterize(&self, should_rasterize: bool)
pub fn setShouldRasterize(&self, should_rasterize: bool)
Setter for shouldRasterize
.
pub fn rasterizationScale(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setRasterizationScale(&self, rasterization_scale: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setRasterizationScale(&self, rasterization_scale: CGFloat)
objc2-core-foundation
only.Setter for rasterizationScale
.
Sourcepub fn shadowColor(&self) -> Option<Retained<CGColor>>
Available on crate feature objc2-core-graphics
only.
pub fn shadowColor(&self) -> Option<Retained<CGColor>>
objc2-core-graphics
only.Shadow properties. *
Sourcepub fn setShadowColor(&self, shadow_color: Option<&CGColor>)
Available on crate feature objc2-core-graphics
only.
pub fn setShadowColor(&self, shadow_color: Option<&CGColor>)
objc2-core-graphics
only.Setter for shadowColor
.
pub fn shadowOpacity(&self) -> c_float
Sourcepub fn setShadowOpacity(&self, shadow_opacity: c_float)
pub fn setShadowOpacity(&self, shadow_opacity: c_float)
Setter for shadowOpacity
.
pub fn shadowOffset(&self) -> CGSize
objc2-core-foundation
only.Sourcepub fn setShadowOffset(&self, shadow_offset: CGSize)
Available on crate feature objc2-core-foundation
only.
pub fn setShadowOffset(&self, shadow_offset: CGSize)
objc2-core-foundation
only.Setter for shadowOffset
.
pub fn shadowRadius(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setShadowRadius(&self, shadow_radius: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setShadowRadius(&self, shadow_radius: CGFloat)
objc2-core-foundation
only.Setter for shadowRadius
.
pub fn shadowPath(&self) -> Option<Retained<CGPath>>
objc2-core-graphics
only.Sourcepub fn setShadowPath(&self, shadow_path: Option<&CGPath>)
Available on crate feature objc2-core-graphics
only.
pub fn setShadowPath(&self, shadow_path: Option<&CGPath>)
objc2-core-graphics
only.Setter for shadowPath
.
Sourcepub fn autoresizingMask(&self) -> CAAutoresizingMask
pub fn autoresizingMask(&self) -> CAAutoresizingMask
Layout methods. *
Sourcepub fn setAutoresizingMask(&self, autoresizing_mask: CAAutoresizingMask)
pub fn setAutoresizingMask(&self, autoresizing_mask: CAAutoresizingMask)
Setter for autoresizingMask
.
pub fn layoutManager( &self, ) -> Option<Retained<ProtocolObject<dyn CALayoutManager>>>
Sourcepub fn setLayoutManager(
&self,
layout_manager: Option<&ProtocolObject<dyn CALayoutManager>>,
)
pub fn setLayoutManager( &self, layout_manager: Option<&ProtocolObject<dyn CALayoutManager>>, )
Setter for layoutManager
.
pub fn preferredFrameSize(&self) -> CGSize
objc2-core-foundation
only.pub fn setNeedsLayout(&self)
pub fn needsLayout(&self) -> bool
pub fn layoutIfNeeded(&self)
pub fn layoutSublayers(&self)
pub fn resizeSublayersWithOldSize(&self, size: CGSize)
objc2-core-foundation
only.pub fn resizeWithOldSuperlayerSize(&self, size: CGSize)
objc2-core-foundation
only.pub fn actionForKey( &self, event: &NSString, ) -> Option<Retained<ProtocolObject<dyn CAAction>>>
pub fn actions( &self, ) -> Option<Retained<NSDictionary<NSString, ProtocolObject<dyn CAAction>>>>
Sourcepub fn setActions(
&self,
actions: Option<&NSDictionary<NSString, ProtocolObject<dyn CAAction>>>,
)
pub fn setActions( &self, actions: Option<&NSDictionary<NSString, ProtocolObject<dyn CAAction>>>, )
Sourcepub fn addAnimation_forKey(&self, anim: &CAAnimation, key: Option<&NSString>)
Available on crate feature CAAnimation
only.
pub fn addAnimation_forKey(&self, anim: &CAAnimation, key: Option<&NSString>)
CAAnimation
only.Animation methods. *
pub fn removeAllAnimations(&self)
pub fn removeAnimationForKey(&self, key: &NSString)
pub fn animationKeys(&self) -> Option<Retained<NSArray<NSString>>>
pub unsafe fn animationForKey( &self, key: &NSString, ) -> Option<Retained<CAAnimation>>
CAAnimation
only.pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn CALayerDelegate>>>
Sourcepub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CALayerDelegate>>,
)
pub fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn CALayerDelegate>>, )
Setter for delegate
.
This is a weak property.
pub fn style(&self) -> Option<Retained<NSDictionary>>
Sourcepub unsafe fn setStyle(&self, style: Option<&NSDictionary>)
pub unsafe fn setStyle(&self, style: Option<&NSDictionary>)
pub fn scrollPoint(&self, p: CGPoint)
CAScrollLayer
and objc2-core-foundation
only.pub fn scrollRectToVisible(&self, r: CGRect)
CAScrollLayer
and objc2-core-foundation
only.pub fn visibleRect(&self) -> CGRect
CAScrollLayer
and objc2-core-foundation
only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
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.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§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 fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for CATransformLayer
impl AsRef<AnyObject> for CATransformLayer
Source§impl AsRef<CALayer> for CATransformLayer
impl AsRef<CALayer> for CATransformLayer
Source§impl AsRef<CATransformLayer> for CATransformLayer
impl AsRef<CATransformLayer> for CATransformLayer
Source§impl AsRef<NSObject> for CATransformLayer
impl AsRef<NSObject> for CATransformLayer
Source§impl Borrow<AnyObject> for CATransformLayer
impl Borrow<AnyObject> for CATransformLayer
Source§impl Borrow<CALayer> for CATransformLayer
impl Borrow<CALayer> for CATransformLayer
Source§impl Borrow<NSObject> for CATransformLayer
impl Borrow<NSObject> for CATransformLayer
Source§impl CAMediaTiming for CATransformLayer
impl CAMediaTiming for CATransformLayer
Source§fn beginTime(&self) -> CFTimeInterval
fn beginTime(&self) -> CFTimeInterval
CAMediaTiming
and objc2-core-foundation
only.Source§fn setBeginTime(&self, begin_time: CFTimeInterval)
fn setBeginTime(&self, begin_time: CFTimeInterval)
CAMediaTiming
and objc2-core-foundation
only.beginTime
.Source§fn duration(&self) -> CFTimeInterval
fn duration(&self) -> CFTimeInterval
CAMediaTiming
and objc2-core-foundation
only.Source§fn setDuration(&self, duration: CFTimeInterval)
fn setDuration(&self, duration: CFTimeInterval)
CAMediaTiming
and objc2-core-foundation
only.duration
.Source§fn setSpeed(&self, speed: c_float)
fn setSpeed(&self, speed: c_float)
CAMediaTiming
only.speed
.Source§fn timeOffset(&self) -> CFTimeInterval
fn timeOffset(&self) -> CFTimeInterval
CAMediaTiming
and objc2-core-foundation
only.Source§fn setTimeOffset(&self, time_offset: CFTimeInterval)
fn setTimeOffset(&self, time_offset: CFTimeInterval)
CAMediaTiming
and objc2-core-foundation
only.timeOffset
.Source§fn repeatCount(&self) -> c_float
fn repeatCount(&self) -> c_float
CAMediaTiming
only.Source§fn setRepeatCount(&self, repeat_count: c_float)
fn setRepeatCount(&self, repeat_count: c_float)
CAMediaTiming
only.repeatCount
.Source§fn repeatDuration(&self) -> CFTimeInterval
fn repeatDuration(&self) -> CFTimeInterval
CAMediaTiming
and objc2-core-foundation
only.Source§fn setRepeatDuration(&self, repeat_duration: CFTimeInterval)
fn setRepeatDuration(&self, repeat_duration: CFTimeInterval)
CAMediaTiming
and objc2-core-foundation
only.repeatDuration
.Source§fn autoreverses(&self) -> bool
fn autoreverses(&self) -> bool
CAMediaTiming
only.Source§fn setAutoreverses(&self, autoreverses: bool)
fn setAutoreverses(&self, autoreverses: bool)
CAMediaTiming
only.autoreverses
.Source§fn fillMode(&self) -> Retained<CAMediaTimingFillMode>
fn fillMode(&self) -> Retained<CAMediaTimingFillMode>
CAMediaTiming
only.Source§fn setFillMode(&self, fill_mode: &CAMediaTimingFillMode)
fn setFillMode(&self, fill_mode: &CAMediaTimingFillMode)
CAMediaTiming
only.Source§impl ClassType for CATransformLayer
impl ClassType for CATransformLayer
Source§const NAME: &'static str = "CATransformLayer"
const NAME: &'static str = "CATransformLayer"
Source§type ThreadKind = <<CATransformLayer as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<CATransformLayer as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for CATransformLayer
impl Debug for CATransformLayer
Source§impl DefaultRetained for CATransformLayer
impl DefaultRetained for CATransformLayer
Source§impl Deref for CATransformLayer
impl Deref for CATransformLayer
Source§impl Hash for CATransformLayer
impl Hash for CATransformLayer
Source§impl Message for CATransformLayer
impl Message for CATransformLayer
Source§impl NSObjectProtocol for CATransformLayer
impl NSObjectProtocol for CATransformLayer
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref