Struct SCNCamera

Source
#[repr(C)]
pub struct SCNCamera { /* private fields */ }
Available on crate feature SCNCamera only.
Expand description

SCNCamera represents a camera that can be attached to a SCNNode.

A node with a camera can be used as a point of view to visualize a 3D scene.

See also Apple’s documentation

Implementations§

Source§

impl SCNCamera

SCNModelIO.

Source

pub unsafe fn cameraWithMDLCamera(mdl_camera: &MDLCamera) -> Retained<Self>

Available on crate feature ModelIO and crate feature objc2-model-io and non-watchOS only.
Source§

impl SCNCamera

Source

pub unsafe fn camera() -> Retained<Self>

Creates and returns a camera instance.

Source

pub unsafe fn name(&self) -> Option<Retained<NSString>>

Determines the name of the receiver.

Source

pub unsafe fn setName(&self, name: Option<&NSString>)

Setter for name.

Source

pub unsafe fn fieldOfView(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the receiver’s field of view (in degree). Defaults to 60°. Animatable.

The fieldOfView is automatically updated when the sensorHeight or focalLength are set. Setting the fieldOfView will update the focalLength according to the new fieldOfView and the current sensorHeight.

Source

pub unsafe fn setFieldOfView(&self, field_of_view: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for fieldOfView.

Source

pub unsafe fn projectionDirection(&self) -> SCNCameraProjectionDirection

Determines whether the fieldOfView (or orthographicScale) is vertical or horizontal. Defaults to vertical.

Source

pub unsafe fn setProjectionDirection( &self, projection_direction: SCNCameraProjectionDirection, )

Setter for projectionDirection.

Source

pub unsafe fn focalLength(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the receiver’s focal length in millimeter. Defaults to 50mm. Animatable.

The focalLength is automatically updated when the sensorHeight or fieldOfView are set. Setting the focalLength will update the fieldOfView according to the new focalLength and the current sensorHeight.

Source

pub unsafe fn setFocalLength(&self, focal_length: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for focalLength.

Source

pub unsafe fn sensorHeight(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the vertical size of the sensor in millimeter. Defaults to 24mm. Animatable.

Setting the sensorHeight will automatically update the fieldOfView according to the new sensorHeight and the current focalLength.

Source

pub unsafe fn setSensorHeight(&self, sensor_height: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for sensorHeight.

Source

pub unsafe fn zNear(&self) -> c_double

Determines the receiver’s near value. Animatable.

The near value determines the minimal distance between the camera and a visible surface. If a surface is closer to the camera than this minimal distance, then the surface is clipped. The near value must be different than zero. Defaults to 1.

Source

pub unsafe fn setZNear(&self, z_near: c_double)

Setter for zNear.

Source

pub unsafe fn zFar(&self) -> c_double

Determines the receiver’s far value. Animatable.

The far value determines the maximal distance between the camera and a visible surface. If a surface is further from the camera than this maximal distance, then the surface is clipped. Defaults to 100.

Source

pub unsafe fn setZFar(&self, z_far: c_double)

Setter for zFar.

Source

pub unsafe fn automaticallyAdjustsZRange(&self) -> bool

Determines whether the receiver automatically adjusts the zFar value. Defaults to NO.

When set to YES, the near and far planes are automatically set to fit the bounding box of the entire scene at render time.

Source

pub unsafe fn setAutomaticallyAdjustsZRange( &self, automatically_adjusts_z_range: bool, )

Source

pub unsafe fn usesOrthographicProjection(&self) -> bool

Determines whether the receiver uses an orthographic projection or not. Defaults to NO.

Source

pub unsafe fn setUsesOrthographicProjection( &self, uses_orthographic_projection: bool, )

Source

pub unsafe fn orthographicScale(&self) -> c_double

Determines the receiver’s orthographic scale value. Animatable. Defaults to 1.

This setting determines the size of the camera’s visible area. This is only enabled when usesOrthographicProjection is set to YES.

Source

pub unsafe fn setOrthographicScale(&self, orthographic_scale: c_double)

Setter for orthographicScale.

Source

pub unsafe fn projectionTransform(&self) -> SCNMatrix4

Available on crate feature SceneKitTypes and crate feature objc2-quartz-core and non-watchOS only.

Determines the projection transform used by the camera to project the world onscreen.

Source

pub unsafe fn setProjectionTransform(&self, projection_transform: SCNMatrix4)

Available on crate feature SceneKitTypes and crate feature objc2-quartz-core and non-watchOS only.

Setter for projectionTransform.

Source

pub unsafe fn projectionTransformWithViewportSize( &self, viewport_size: CGSize, ) -> SCNMatrix4

Available on crate feature SceneKitTypes and crate feature objc2-core-foundation and crate feature objc2-quartz-core and non-watchOS only.
Source

pub unsafe fn wantsDepthOfField(&self) -> bool

Determines if the receiver has depth of field. Defaults to NO.

Source

pub unsafe fn setWantsDepthOfField(&self, wants_depth_of_field: bool)

Setter for wantsDepthOfField.

Source

pub unsafe fn focusDistance(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the receiver’s focus distance. Animatable.

Defaults to 2.5

Source

pub unsafe fn setFocusDistance(&self, focus_distance: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for focusDistance.

Source

pub unsafe fn focalBlurSampleCount(&self) -> NSInteger

Determines the receiver’s sample count for depth of field effect.

Defaults to 25.

Source

pub unsafe fn setFocalBlurSampleCount(&self, focal_blur_sample_count: NSInteger)

Source

pub unsafe fn fStop(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the receiver’s fstop. Animatable.

Defaults to 5.6.

Source

pub unsafe fn setFStop(&self, f_stop: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for fStop.

Source

pub unsafe fn apertureBladeCount(&self) -> NSInteger

Determines the receiver’s blade count of the aperture.

Defaults to 6.

Source

pub unsafe fn setApertureBladeCount(&self, aperture_blade_count: NSInteger)

Setter for apertureBladeCount.

Source

pub unsafe fn motionBlurIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the intensity of the motion blur. Animatable. Defaults to 0.

An intensity of zero means no motion blur. The intensity should not exceeed 1.

Source

pub unsafe fn setMotionBlurIntensity(&self, motion_blur_intensity: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for motionBlurIntensity.

Source

pub unsafe fn screenSpaceAmbientOcclusionIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the intensity of the screen space ambient occlusion. Animatable.

defaults to 0.

Source

pub unsafe fn setScreenSpaceAmbientOcclusionIntensity( &self, screen_space_ambient_occlusion_intensity: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn screenSpaceAmbientOcclusionRadius(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the screen space ambient occlusion radius in scene unit. Animatable.

defaults to 5.

Source

pub unsafe fn setScreenSpaceAmbientOcclusionRadius( &self, screen_space_ambient_occlusion_radius: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn screenSpaceAmbientOcclusionBias(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines self occlusion bias in scene unit.

defaults to 0.03.

Source

pub unsafe fn setScreenSpaceAmbientOcclusionBias( &self, screen_space_ambient_occlusion_bias: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn screenSpaceAmbientOcclusionDepthThreshold(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the depth blur threshold in scene unit.

defaults to 0.2.

Source

pub unsafe fn setScreenSpaceAmbientOcclusionDepthThreshold( &self, screen_space_ambient_occlusion_depth_threshold: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn screenSpaceAmbientOcclusionNormalThreshold(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the normal blur threshold.

defaults to 0.3.

Source

pub unsafe fn setScreenSpaceAmbientOcclusionNormalThreshold( &self, screen_space_ambient_occlusion_normal_threshold: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn wantsHDR(&self) -> bool

Determines if the receiver has a high dynamic range. Defaults to NO.

Source

pub unsafe fn setWantsHDR(&self, wants_hdr: bool)

Setter for wantsHDR.

Source

pub unsafe fn exposureOffset(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the logarithmic exposure biasing, in EV. Defaults to 0.

Source

pub unsafe fn setExposureOffset(&self, exposure_offset: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for exposureOffset.

Source

pub unsafe fn averageGray(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the average gray level desired in the final image. Defaults to 0.18.

Source

pub unsafe fn setAverageGray(&self, average_gray: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for averageGray.

Source

pub unsafe fn whitePoint(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the smallest luminance level that will be mapped to white in the final image. Defaults to 1.

Source

pub unsafe fn setWhitePoint(&self, white_point: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for whitePoint.

Source

pub unsafe fn wantsExposureAdaptation(&self) -> bool

Determines if the receiver should simulate an eye and continuously adjust to luminance. Defaults to YES.

Source

pub unsafe fn setWantsExposureAdaptation(&self, wants_exposure_adaptation: bool)

Source

pub unsafe fn exposureAdaptationBrighteningSpeedFactor(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the exposure adaptation speed when going from bright areas to dark areas. Defaults to 0.4.

Source

pub unsafe fn setExposureAdaptationBrighteningSpeedFactor( &self, exposure_adaptation_brightening_speed_factor: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn exposureAdaptationDarkeningSpeedFactor(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the exposure adaptation speed when going from dark areas to bright areas. Defaults to 0.6.

Source

pub unsafe fn setExposureAdaptationDarkeningSpeedFactor( &self, exposure_adaptation_darkening_speed_factor: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn minimumExposure(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the minimum exposure offset of the adaptation, in EV. Defaults to -15.

Source

pub unsafe fn setMinimumExposure(&self, minimum_exposure: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for minimumExposure.

Source

pub unsafe fn maximumExposure(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the maximum exposure offset of the adaptation, in EV. Defaults to -15.

Source

pub unsafe fn setMaximumExposure(&self, maximum_exposure: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for maximumExposure.

Source

pub unsafe fn bloomThreshold(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the luminance threshold for the bloom effect. Animatable. Defaults to 1.

Source

pub unsafe fn setBloomThreshold(&self, bloom_threshold: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for bloomThreshold.

Source

pub unsafe fn bloomIterationCount(&self) -> NSInteger

Determines the number of blur iterations. Defaults to 1.

Source

pub unsafe fn setBloomIterationCount(&self, bloom_iteration_count: NSInteger)

Setter for bloomIterationCount.

Source

pub unsafe fn bloomIterationSpread(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines how the bloom iterations are spread. Defaults to 0.

Source

pub unsafe fn setBloomIterationSpread(&self, bloom_iteration_spread: CGFloat)

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn bloomIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the intensity of the bloom effect. Animatable. Defaults to 0 (no effect).

Source

pub unsafe fn setBloomIntensity(&self, bloom_intensity: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for bloomIntensity.

Source

pub unsafe fn bloomBlurRadius(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Determines the radius of the bloom effect in points. Animatable. Defaults to 4.

Source

pub unsafe fn setBloomBlurRadius(&self, bloom_blur_radius: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for bloomBlurRadius.

Source

pub unsafe fn vignettingPower(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the shape of the vignetting effect. Defaults to 0 (no effect).

Source

pub unsafe fn setVignettingPower(&self, vignetting_power: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for vignettingPower.

Source

pub unsafe fn vignettingIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the intensity of the vignetting effect. Defaults to 0 (no effect).

Source

pub unsafe fn setVignettingIntensity(&self, vignetting_intensity: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for vignettingIntensity.

Source

pub unsafe fn colorFringeStrength(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the strength of the color shift effect. Defaults to 0 (no effect).

Source

pub unsafe fn setColorFringeStrength(&self, color_fringe_strength: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for colorFringeStrength.

Source

pub unsafe fn colorFringeIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the intensity of the color shift effect. Defaults to 1.

Source

pub unsafe fn setColorFringeIntensity(&self, color_fringe_intensity: CGFloat)

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn saturation(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the overall saturation of the scene. Defaults to 1 (no effect).

Source

pub unsafe fn setSaturation(&self, saturation: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for saturation.

Source

pub unsafe fn contrast(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the overall contrast of the scene. Defaults to 0 (no effect).

Source

pub unsafe fn setContrast(&self, contrast: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for contrast.

Source

pub unsafe fn grainIntensity(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the intensity of the grain. Defaults to 0 (no effect).

Source

pub unsafe fn setGrainIntensity(&self, grain_intensity: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for grainIntensity.

Source

pub unsafe fn grainScale(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the scale of the grain. Defaults to 1.

Source

pub unsafe fn setGrainScale(&self, grain_scale: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for grainScale.

Source

pub unsafe fn grainIsColored(&self) -> bool

Determines if the grain is colored or not. Defaults to NO.

Source

pub unsafe fn setGrainIsColored(&self, grain_is_colored: bool)

Setter for grainIsColored.

Source

pub unsafe fn whiteBalanceTemperature(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the overall white balance temperature of the scene. Defaults to 0 (no effect).

Source

pub unsafe fn setWhiteBalanceTemperature( &self, white_balance_temperature: CGFloat, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn whiteBalanceTint(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls the overall white balance tint of the scene. Defaults to 0 (no effect).

Source

pub unsafe fn setWhiteBalanceTint(&self, white_balance_tint: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for whiteBalanceTint.

Source

pub unsafe fn colorGrading(&self) -> Retained<SCNMaterialProperty>

Available on crate feature SCNMaterialProperty only.

Specifies a lookup texture to apply color grading. The contents must a 2D image representing n slices of a unit color cube texture, arranged in an horizontal row of n images. For instance, a color cube of dimension 16x16x16 should be provided as an image of size 256x16.

Source

pub unsafe fn categoryBitMask(&self) -> NSUInteger

Determines the node categories that are visible from the receiver. Defaults to all bits set.

Source

pub unsafe fn setCategoryBitMask(&self, category_bit_mask: NSUInteger)

Setter for categoryBitMask.

Source§

impl SCNCamera

Methods declared on superclass NSObject.

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub unsafe fn new() -> Retained<Self>

Source§

impl SCNCamera

SCNDeprecated.

Source

pub unsafe fn focalBlurRadius(&self) -> CGFloat

👎Deprecated: Use fStop instead
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Determines the receiver’s focal radius. Animatable.

Determines the maximum amount of blur for objects out of focus. Defaults to 0.

Source

pub unsafe fn setFocalBlurRadius(&self, focal_blur_radius: CGFloat)

👎Deprecated: Use fStop instead
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Setter for focalBlurRadius.

Source

pub unsafe fn xFov(&self) -> c_double

👎Deprecated: Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead
Available on crate feature SceneKitDeprecated only.

Determines the receiver’s field of view on the X axis (in degree). Animatable.

When both xFov and yFov are null an yFov of 60° is used. When both are set, the one that best fits the renderer’s aspect ratio is used. When only one is set, it is used. Defaults to 0.

Source

pub unsafe fn setXFov(&self, x_fov: c_double)

👎Deprecated: Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead
Available on crate feature SceneKitDeprecated only.

Setter for xFov.

Source

pub unsafe fn yFov(&self) -> c_double

👎Deprecated: Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead
Available on crate feature SceneKitDeprecated only.

Determines the receiver’s field of view on the Y axis (in degree). Animatable.

When both xFov and yFov are null an yFov of 60° is used. When both are set, the one that best fits the renderer’s aspect ratio is used. When only one is set, it is used. Defaults to 0.

Source

pub unsafe fn setYFov(&self, y_fov: c_double)

👎Deprecated: Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead
Available on crate feature SceneKitDeprecated only.

Setter for yFov.

Source

pub unsafe fn aperture(&self) -> CGFloat

👎Deprecated: Use -[SCNCamera fStop] instead with fStop = sensorHeight / aperture.
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Determines the receiver’s aperture. Animatable.

Defaults to 1/8.0.

Source

pub unsafe fn setAperture(&self, aperture: CGFloat)

👎Deprecated: Use -[SCNCamera fStop] instead with fStop = sensorHeight / aperture.
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Setter for aperture.

Source

pub unsafe fn focalSize(&self) -> CGFloat

👎Deprecated
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Determines the receiver’s focal size. Animatable.

Determines the size of the area around focalDistance where the objects are in focus. Defaults to 0.

Source

pub unsafe fn setFocalSize(&self, focal_size: CGFloat)

👎Deprecated
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Setter for focalSize.

Source

pub unsafe fn focalDistance(&self) -> CGFloat

👎Deprecated
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Determines the receiver’s focal distance. Animatable.

When non zero, the focal distance determines how the camera focuses the objects in the 3d scene. Defaults to 10.0 prior to macOS 10.13, iOS 11, tvOS 11 and watchOS 4. Defaults to 2.5 otherwise.

Source

pub unsafe fn setFocalDistance(&self, focal_distance: CGFloat)

👎Deprecated
Available on crate features SceneKitDeprecated and objc2-core-foundation only.

Setter for focalDistance.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

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());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use 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.

Source

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 SCNCamera

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<NSObject> for SCNCamera

Source§

fn as_ref(&self) -> &NSObject

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

impl AsRef<SCNCamera> for SCNCamera

Source§

fn as_ref(&self) -> &Self

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

impl Borrow<AnyObject> for SCNCamera

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for SCNCamera

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for SCNCamera

Source§

const NAME: &'static str = "SCNCamera"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = NSObject

The superclass of this class. Read more
Source§

type ThreadKind = <<SCNCamera as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl CopyingHelper for SCNCamera

Source§

type Result = SCNCamera

The immutable counterpart of the type, or Self if the type has no immutable counterpart. Read more
Source§

impl Debug for SCNCamera

Source§

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

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

impl Deref for SCNCamera

Source§

type Target = NSObject

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for SCNCamera

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SCNCamera

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSCoding for SCNCamera

Source§

unsafe fn encodeWithCoder(&self, coder: &NSCoder)
where Self: Sized + Message,

Available on crate feature NSCoder only.
Source§

unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
where Self: Sized + Message,

Available on crate feature NSCoder only.
Source§

impl NSCopying for SCNCamera

Source§

fn copy(&self) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

impl NSObjectProtocol for SCNCamera

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl NSSecureCoding for SCNCamera

Source§

unsafe fn supportsSecureCoding() -> bool
where Self: Sized + ClassType,

Source§

impl PartialEq for SCNCamera

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 RefEncode for SCNCamera

Source§

const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl SCNAnimatable for SCNCamera

Available on crate feature SCNAnimation only.
Source§

unsafe fn addAnimation_forKey( &self, animation: &ProtocolObject<dyn SCNAnimationProtocol>, key: Option<&NSString>, )
where Self: Sized + Message,

Adds and runs an animation Read more
Source§

unsafe fn addAnimationPlayer_forKey( &self, player: &SCNAnimationPlayer, key: Option<&NSString>, )
where Self: Sized + Message,

Add an animation player. Read more
Source§

unsafe fn removeAllAnimations(&self)
where Self: Sized + Message,

Remove all animations.
Source§

unsafe fn removeAllAnimationsWithBlendOutDuration(&self, duration: CGFloat)
where Self: Sized + Message,

Available on crate feature objc2-core-foundation only.
Smoothly remove all animations. Read more
Source§

unsafe fn removeAnimationForKey(&self, key: &NSString)
where Self: Sized + Message,

Remove the animation with the given identifier. Read more
Source§

unsafe fn removeAnimationForKey_blendOutDuration( &self, key: &NSString, duration: CGFloat, )
where Self: Sized + Message,

Available on crate feature objc2-core-foundation only.
Smoothly remove the animation with the given identifier. Read more
Source§

unsafe fn animationKeys(&self) -> Retained<NSArray<NSString>>
where Self: Sized + Message,

Returns an array containing the keys of all animations currently attached to the receiver.
Source§

unsafe fn animationPlayerForKey( &self, key: &NSString, ) -> Option<Retained<SCNAnimationPlayer>>
where Self: Sized + Message,

Returns the animation player with the given identifier Read more
Source§

unsafe fn removeAnimationForKey_fadeOutDuration( &self, key: &NSString, duration: CGFloat, )
where Self: Sized + Message,

👎Deprecated
Available on crate feature objc2-core-foundation only.
Smoothly remove the animation with the given identifier. Read more
Source§

unsafe fn animationForKey( &self, key: &NSString, ) -> Option<Retained<CAAnimation>>
where Self: Sized + Message,

👎Deprecated
Available on crate feature objc2-quartz-core and non-watchOS only.
Returns the animation with the given identifier Read more
Source§

unsafe fn pauseAnimationForKey(&self, key: &NSString)
where Self: Sized + Message,

👎Deprecated: Use -[SCNAnimationPlayer setPaused:] instead
Pause the animation with the given identifier. Read more
Source§

unsafe fn resumeAnimationForKey(&self, key: &NSString)
where Self: Sized + Message,

👎Deprecated: Use -[SCNAnimationPlayer setPaused:] instead
Resume the animation with the given identifier. Read more
Source§

unsafe fn setSpeed_forAnimationKey(&self, speed: CGFloat, key: &NSString)
where Self: Sized + Message,

👎Deprecated: Use -[SCNAnimationPlayer setSpeed:] instead
Available on crate feature objc2-core-foundation only.
Update the animation speed of the animation with the given identifier. Read more
Source§

unsafe fn isAnimationForKeyPaused(&self, key: &NSString) -> bool
where Self: Sized + Message,

👎Deprecated: Use -[SCNAnimationPlayer paused] instead
Returns whether the animation for the specified identifier is paused. Read more
Source§

impl SCNTechniqueSupport for SCNCamera

Available on crate feature SCNTechnique only.
Source§

unsafe fn technique(&self) -> Option<Retained<SCNTechnique>>
where Self: Sized + Message,

Specifies the technique of the receiver. Defaults to nil.
Source§

unsafe fn setTechnique(&self, technique: Option<&SCNTechnique>)
where Self: Sized + Message,

Setter for technique.
Source§

impl DowncastTarget for SCNCamera

Source§

impl Eq for SCNCamera

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<'a, T> AllocAnyThread for T
where T: ClassType<ThreadKind = dyn AllocAnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. Read more
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, 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.
Source§

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