#[repr(C)]pub struct TVDigitEntryViewController { /* private fields */ }TVDigitEntryViewController only.Expand description
Implementations§
Source§impl TVDigitEntryViewController
impl TVDigitEntryViewController
Sourcepub unsafe fn entryCompletionHandler(
&self,
) -> NonNull<DynBlock<dyn Fn(NonNull<NSString>)>>
Available on crate feature block2 only.
pub unsafe fn entryCompletionHandler( &self, ) -> NonNull<DynBlock<dyn Fn(NonNull<NSString>)>>
block2 only.Entry completion handler.
This is called when the number of digits entered reaches .numberOfDigits.
Parameter entry: Digits entered.
Sourcepub unsafe fn setEntryCompletionHandler(
&self,
entry_completion_handler: &DynBlock<dyn Fn(NonNull<NSString>)>,
)
Available on crate feature block2 only.
pub unsafe fn setEntryCompletionHandler( &self, entry_completion_handler: &DynBlock<dyn Fn(NonNull<NSString>)>, )
block2 only.Setter for entryCompletionHandler.
Sourcepub unsafe fn titleText(&self) -> Option<Retained<NSString>>
pub unsafe fn titleText(&self) -> Option<Retained<NSString>>
The title text.
This is presented at the top of the digit entry view.
Sourcepub unsafe fn setTitleText(&self, title_text: Option<&NSString>)
pub unsafe fn setTitleText(&self, title_text: Option<&NSString>)
Setter for titleText.
Sourcepub unsafe fn promptText(&self) -> Option<Retained<NSString>>
pub unsafe fn promptText(&self) -> Option<Retained<NSString>>
The prompt text.
This is presented immediately below titleText.
Sourcepub unsafe fn setPromptText(&self, prompt_text: Option<&NSString>)
pub unsafe fn setPromptText(&self, prompt_text: Option<&NSString>)
Setter for promptText.
Sourcepub unsafe fn isSecureDigitEntry(&self) -> bool
pub unsafe fn isSecureDigitEntry(&self) -> bool
Determines whether the entered digit is immediately obsecured.
Default is NO.
Sourcepub unsafe fn setSecureDigitEntry(&self, secure_digit_entry: bool)
pub unsafe fn setSecureDigitEntry(&self, secure_digit_entry: bool)
Setter for isSecureDigitEntry.
Sourcepub unsafe fn numberOfDigits(&self) -> NSUInteger
pub unsafe fn numberOfDigits(&self) -> NSUInteger
Determines the number of digits asked for by the digit entry view.
Default is 4.
Sourcepub unsafe fn setNumberOfDigits(&self, number_of_digits: NSUInteger)
pub unsafe fn setNumberOfDigits(&self, number_of_digits: NSUInteger)
Setter for numberOfDigits.
Sourcepub unsafe fn clearEntryAnimated(&self, animated: bool)
pub unsafe fn clearEntryAnimated(&self, animated: bool)
Clears all the digits from the digit entry view.
Parameter animated: If YES the digit entry view will animate.
Source§impl TVDigitEntryViewController
Methods declared on superclass UIViewController.
impl TVDigitEntryViewController
Methods declared on superclass UIViewController.
Methods from Deref<Target = UIViewController>§
pub fn view(&self) -> Option<Retained<UIView>>
pub unsafe fn loadView(&self)
pub unsafe fn loadViewIfNeeded(&self)
pub unsafe fn viewIfLoaded(&self) -> Option<Retained<UIView>>
pub unsafe fn viewWillUnload(&self)
pub unsafe fn viewDidUnload(&self)
pub unsafe fn viewDidLoad(&self)
pub unsafe fn isViewLoaded(&self) -> bool
pub unsafe fn nibName(&self) -> Option<Retained<NSString>>
pub unsafe fn nibBundle(&self) -> Option<Retained<NSBundle>>
pub unsafe fn performSegueWithIdentifier_sender( &self, identifier: &NSString, sender: Option<&AnyObject>, )
pub unsafe fn shouldPerformSegueWithIdentifier_sender( &self, identifier: &NSString, sender: Option<&AnyObject>, ) -> bool
pub unsafe fn canPerformUnwindSegueAction_fromViewController_sender( &self, action: Sel, from_view_controller: &UIViewController, sender: Option<&AnyObject>, ) -> bool
pub unsafe fn canPerformUnwindSegueAction_fromViewController_withSender( &self, action: Sel, from_view_controller: &UIViewController, sender: &AnyObject, ) -> bool
pub unsafe fn viewControllerForUnwindSegueAction_fromViewController_withSender( &self, action: Sel, from_view_controller: &UIViewController, sender: Option<&AnyObject>, ) -> Option<Retained<UIViewController>>
Sourcepub unsafe fn viewWillAppear(&self, animated: bool)
pub unsafe fn viewWillAppear(&self, animated: bool)
Called when the view is about to made visible, before it is added to the hierarchy. Because the view is not yet in the hierarchy at the time this method is called, it is too early in the appearance transition for many usages. Prefer -viewIsAppearing: instead of this method when possible. Only use this method when its exact timing before the appearance transition starts running is desired, such as to set up an alongside animation with a transition coordinator, or as a counterpart for paired code in a viewWillDisappear/viewDidDisappear callback that does not rely on the view or view controller’s trait collection or the view hierarchy.
Sourcepub unsafe fn viewIsAppearing(&self, animated: bool)
pub unsafe fn viewIsAppearing(&self, animated: bool)
Called when the view is becoming visible at the beginning of the appearance transition, after it has been added to the hierarchy and been laid out by its superview. This method is very similar to -viewWillAppear: and is always called shortly afterwards (so changes made in either callback will be visible to the user at the same time), but unlike -viewWillAppear:, at the time when -viewIsAppearing: is called all of the following are valid for the view controller and its own view:
- View controller and view’s trait collection
- View’s superview chain and window
- View’s geometry (e.g. frame/bounds, safe area insets, layout margins) Choose this method instead of -viewWillAppear: by default, as it is a direct replacement that provides equivalent or superior behavior in nearly all cases.
Sourcepub unsafe fn viewDidAppear(&self, animated: bool)
pub unsafe fn viewDidAppear(&self, animated: bool)
Called after the view has fully transitioned to visible, when any transition animations have completed.
Sourcepub unsafe fn viewWillDisappear(&self, animated: bool)
pub unsafe fn viewWillDisappear(&self, animated: bool)
Called when the view is about to be dismissed, covered, or otherwise hidden.
Sourcepub unsafe fn viewDidDisappear(&self, animated: bool)
pub unsafe fn viewDidDisappear(&self, animated: bool)
Called after the view has fully been dismissed, covered, or otherwise hidden, when any transition animations have completed.
pub unsafe fn viewWillLayoutSubviews(&self)
pub unsafe fn viewDidLayoutSubviews(&self)
pub unsafe fn title(&self) -> Option<Retained<NSString>>
pub unsafe fn didReceiveMemoryWarning(&self)
pub unsafe fn parentViewController(&self) -> Option<Retained<UIViewController>>
pub unsafe fn modalViewController(&self) -> Option<Retained<UIViewController>>
pub unsafe fn presentedViewController( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn presentingViewController( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn definesPresentationContext(&self) -> bool
Sourcepub unsafe fn setDefinesPresentationContext(
&self,
defines_presentation_context: bool,
)
pub unsafe fn setDefinesPresentationContext( &self, defines_presentation_context: bool, )
Setter for definesPresentationContext.
pub unsafe fn providesPresentationContextTransitionStyle(&self) -> bool
Sourcepub unsafe fn setProvidesPresentationContextTransitionStyle(
&self,
provides_presentation_context_transition_style: bool,
)
pub unsafe fn setProvidesPresentationContextTransitionStyle( &self, provides_presentation_context_transition_style: bool, )
Setter for providesPresentationContextTransitionStyle.
pub unsafe fn restoresFocusAfterTransition(&self) -> bool
Sourcepub unsafe fn setRestoresFocusAfterTransition(
&self,
restores_focus_after_transition: bool,
)
pub unsafe fn setRestoresFocusAfterTransition( &self, restores_focus_after_transition: bool, )
Setter for restoresFocusAfterTransition.
Sourcepub unsafe fn focusGroupIdentifier(&self) -> Option<Retained<NSString>>
pub unsafe fn focusGroupIdentifier(&self) -> Option<Retained<NSString>>
The identifier of the focus group that this view controller belongs to. If this is nil, the view controller inherits the focus group of its parent focus environment.
Sourcepub unsafe fn setFocusGroupIdentifier(
&self,
focus_group_identifier: Option<&NSString>,
)
pub unsafe fn setFocusGroupIdentifier( &self, focus_group_identifier: Option<&NSString>, )
Setter for focusGroupIdentifier.
Sourcepub unsafe fn interactionActivityTrackingBaseName(
&self,
) -> Option<Retained<NSString>>
pub unsafe fn interactionActivityTrackingBaseName( &self, ) -> Option<Retained<NSString>>
The base name for tracking user interactions as activities hosted by this view controller.
Sourcepub unsafe fn setInteractionActivityTrackingBaseName(
&self,
interaction_activity_tracking_base_name: Option<&NSString>,
)
pub unsafe fn setInteractionActivityTrackingBaseName( &self, interaction_activity_tracking_base_name: Option<&NSString>, )
Setter for interactionActivityTrackingBaseName.
pub unsafe fn isBeingPresented(&self) -> bool
pub unsafe fn isBeingDismissed(&self) -> bool
pub unsafe fn isMovingToParentViewController(&self) -> bool
pub unsafe fn isMovingFromParentViewController(&self) -> bool
pub unsafe fn presentModalViewController_animated( &self, modal_view_controller: &UIViewController, animated: bool, )
pub unsafe fn dismissModalViewControllerAnimated(&self, animated: bool)
pub unsafe fn modalTransitionStyle(&self) -> UIModalTransitionStyle
Sourcepub unsafe fn setModalTransitionStyle(
&self,
modal_transition_style: UIModalTransitionStyle,
)
pub unsafe fn setModalTransitionStyle( &self, modal_transition_style: UIModalTransitionStyle, )
Setter for modalTransitionStyle.
pub unsafe fn modalPresentationStyle(&self) -> UIModalPresentationStyle
Sourcepub unsafe fn setModalPresentationStyle(
&self,
modal_presentation_style: UIModalPresentationStyle,
)
pub unsafe fn setModalPresentationStyle( &self, modal_presentation_style: UIModalPresentationStyle, )
Setter for modalPresentationStyle.
pub unsafe fn modalPresentationCapturesStatusBarAppearance(&self) -> bool
Sourcepub unsafe fn setModalPresentationCapturesStatusBarAppearance(
&self,
modal_presentation_captures_status_bar_appearance: bool,
)
pub unsafe fn setModalPresentationCapturesStatusBarAppearance( &self, modal_presentation_captures_status_bar_appearance: bool, )
Setter for modalPresentationCapturesStatusBarAppearance.
pub unsafe fn disablesAutomaticKeyboardDismissal(&self) -> bool
pub unsafe fn wantsFullScreenLayout(&self) -> bool
Sourcepub unsafe fn setWantsFullScreenLayout(&self, wants_full_screen_layout: bool)
👎Deprecated
pub unsafe fn setWantsFullScreenLayout(&self, wants_full_screen_layout: bool)
Setter for wantsFullScreenLayout.
pub unsafe fn edgesForExtendedLayout(&self) -> UIRectEdge
Sourcepub unsafe fn setEdgesForExtendedLayout(
&self,
edges_for_extended_layout: UIRectEdge,
)
pub unsafe fn setEdgesForExtendedLayout( &self, edges_for_extended_layout: UIRectEdge, )
Setter for edgesForExtendedLayout.
pub unsafe fn extendedLayoutIncludesOpaqueBars(&self) -> bool
Sourcepub unsafe fn setExtendedLayoutIncludesOpaqueBars(
&self,
extended_layout_includes_opaque_bars: bool,
)
pub unsafe fn setExtendedLayoutIncludesOpaqueBars( &self, extended_layout_includes_opaque_bars: bool, )
Setter for extendedLayoutIncludesOpaqueBars.
pub unsafe fn automaticallyAdjustsScrollViewInsets(&self) -> bool
Sourcepub unsafe fn setAutomaticallyAdjustsScrollViewInsets(
&self,
automatically_adjusts_scroll_view_insets: bool,
)
👎Deprecated: Use UIScrollView’s contentInsetAdjustmentBehavior instead
pub unsafe fn setAutomaticallyAdjustsScrollViewInsets( &self, automatically_adjusts_scroll_view_insets: bool, )
Setter for automaticallyAdjustsScrollViewInsets.
Sourcepub unsafe fn setContentScrollView_forEdge(
&self,
scroll_view: Option<&UIScrollView>,
edge: NSDirectionalRectEdge,
)
pub unsafe fn setContentScrollView_forEdge( &self, scroll_view: Option<&UIScrollView>, edge: NSDirectionalRectEdge, )
Aggregate values (e.g., NSDirectionalRectEdgeAll) are accepted in the edge parameter; NSDirectionalRectEdgeLeading and Trailing are ignored on iOS 15.0
Sourcepub unsafe fn contentScrollViewForEdge(
&self,
edge: NSDirectionalRectEdge,
) -> Option<Retained<UIScrollView>>
pub unsafe fn contentScrollViewForEdge( &self, edge: NSDirectionalRectEdge, ) -> Option<Retained<UIScrollView>>
Pass only a single edge (e.g., NSDirectionalRectEdgeTop) in the edge parameter. Raises an exception when passed an aggregate edge (e.g., NSDirectionalRectEdgeAll)
pub unsafe fn preferredContentSize(&self) -> CGSize
Sourcepub unsafe fn setPreferredContentSize(&self, preferred_content_size: CGSize)
pub unsafe fn setPreferredContentSize(&self, preferred_content_size: CGSize)
Setter for preferredContentSize.
pub unsafe fn prefersStatusBarHidden(&self) -> bool
pub fn setNeedsStatusBarAppearanceUpdate(&self)
pub unsafe fn targetViewControllerForAction_sender( &self, action: Sel, sender: Option<&AnyObject>, ) -> Option<Retained<UIViewController>>
pub unsafe fn showViewController_sender( &self, vc: &UIViewController, sender: Option<&AnyObject>, )
pub unsafe fn showDetailViewController_sender( &self, vc: &UIViewController, sender: Option<&AnyObject>, )
pub unsafe fn setNeedsUserInterfaceAppearanceUpdate(&self)
pub unsafe fn shouldAutorotate(&self) -> bool
Sourcepub unsafe fn setNeedsUpdateOfSupportedInterfaceOrientations(&self)
pub unsafe fn setNeedsUpdateOfSupportedInterfaceOrientations(&self)
Notifies the view controller that a change occurred that affects supported interface orientations or the preferred interface orientation for presentation.
By default, this will animate any changes to orientation. To perform a non-animated update, call within [UIView performWithoutAnimation:].
pub unsafe fn rotatingHeaderView(&self) -> Option<Retained<UIView>>
pub unsafe fn isEditing(&self) -> bool
Sourcepub unsafe fn setEditing(&self, editing: bool)
pub unsafe fn setEditing(&self, editing: bool)
Setter for isEditing.
pub unsafe fn setEditing_animated(&self, editing: bool, animated: bool)
pub unsafe fn childViewControllers(&self) -> Retained<NSArray<UIViewController>>
pub unsafe fn addChildViewController(&self, child_controller: &UIViewController)
pub unsafe fn removeFromParentViewController(&self)
pub unsafe fn beginAppearanceTransition_animated( &self, is_appearing: bool, animated: bool, )
pub unsafe fn endAppearanceTransition(&self)
pub unsafe fn childViewControllerForStatusBarStyle( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn childViewControllerForStatusBarHidden( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn setOverrideTraitCollection_forChildViewController( &self, collection: Option<&UITraitCollection>, child_view_controller: &UIViewController, )
pub unsafe fn overrideTraitCollectionForChildViewController( &self, child_view_controller: &UIViewController, ) -> Option<Retained<UITraitCollection>>
pub unsafe fn childViewControllerForUserInterfaceStyle( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers( &self, ) -> bool
pub unsafe fn shouldAutomaticallyForwardRotationMethods(&self) -> bool
pub unsafe fn shouldAutomaticallyForwardAppearanceMethods(&self) -> bool
pub unsafe fn willMoveToParentViewController( &self, parent: Option<&UIViewController>, )
pub unsafe fn didMoveToParentViewController( &self, parent: Option<&UIViewController>, )
pub unsafe fn restorationIdentifier(&self) -> Option<Retained<NSString>>
Sourcepub unsafe fn setRestorationIdentifier(
&self,
restoration_identifier: Option<&NSString>,
)
pub unsafe fn setRestorationIdentifier( &self, restoration_identifier: Option<&NSString>, )
Setter for restorationIdentifier.
pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)
pub unsafe fn decodeRestorableStateWithCoder(&self, coder: &NSCoder)
pub unsafe fn applicationFinishedRestoringState(&self)
pub unsafe fn updateViewConstraints(&self)
pub unsafe fn additionalSafeAreaInsets(&self) -> UIEdgeInsets
Sourcepub unsafe fn setAdditionalSafeAreaInsets(
&self,
additional_safe_area_insets: UIEdgeInsets,
)
pub unsafe fn setAdditionalSafeAreaInsets( &self, additional_safe_area_insets: UIEdgeInsets, )
Setter for additionalSafeAreaInsets.
pub unsafe fn systemMinimumLayoutMargins(&self) -> NSDirectionalEdgeInsets
pub unsafe fn viewRespectsSystemMinimumLayoutMargins(&self) -> bool
Sourcepub unsafe fn setViewRespectsSystemMinimumLayoutMargins(
&self,
view_respects_system_minimum_layout_margins: bool,
)
pub unsafe fn setViewRespectsSystemMinimumLayoutMargins( &self, view_respects_system_minimum_layout_margins: bool, )
Setter for viewRespectsSystemMinimumLayoutMargins.
pub unsafe fn viewLayoutMarginsDidChange(&self)
pub unsafe fn viewSafeAreaInsetsDidChange(&self)
Sourcepub unsafe fn performsActionsWhilePresentingModally(&self) -> bool
pub unsafe fn performsActionsWhilePresentingModally(&self) -> bool
Determines whether the receiver continues to respond to actions while it is presenting a view controller modally.
Defaults to YES. You can change the default return value by providing a value for UIViewControllerPerformsActionsWhilePresentingModally in your Info.plist file.
pub unsafe fn extensionContext(&self) -> Option<Retained<NSExtensionContext>>
pub unsafe fn isModalInPresentation(&self) -> bool
Sourcepub unsafe fn setModalInPresentation(&self, modal_in_presentation: bool)
pub unsafe fn setModalInPresentation(&self, modal_in_presentation: bool)
Setter for isModalInPresentation.
pub unsafe fn registerForPreviewingWithDelegate_sourceView( &self, delegate: &ProtocolObject<dyn UIViewControllerPreviewingDelegate>, source_view: &UIView, ) -> Retained<ProtocolObject<dyn UIViewControllerPreviewing>>
pub unsafe fn unregisterForPreviewingWithContext( &self, previewing: &ProtocolObject<dyn UIViewControllerPreviewing>, )
pub unsafe fn childViewControllerForScreenEdgesDeferringSystemGestures( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn preferredScreenEdgesDeferringSystemGestures(&self) -> UIRectEdge
pub fn setNeedsUpdateOfScreenEdgesDeferringSystemGestures(&self)
pub unsafe fn childViewControllerForHomeIndicatorAutoHidden( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn prefersHomeIndicatorAutoHidden(&self) -> bool
pub fn setNeedsUpdateOfHomeIndicatorAutoHidden(&self)
pub unsafe fn childViewControllerForPointerLock( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn prefersPointerLocked(&self) -> bool
pub unsafe fn setNeedsUpdateOfPrefersPointerLocked(&self)
Setting a content unavailable configuration replaces the existing content unavailable view of the view controller with a new content unavailable view instance from the configuration, or directly applies the configuration to the existing content unavailable view if the configuration is compatible with the existing content unavailable view type. The default value is nil.
Setter for contentUnavailableConfiguration.
Requests the view update its content unavailable configuration for its current state. This method is called automatically
when the view’s contentUnavailableConfigurationState may have changed, as well as in other circumstances where an
update may be required. Multiple requests may be coalesced into a single update at the appropriate time.
pub unsafe fn previewActionItems( &self, ) -> Retained<NSArray<ProtocolObject<dyn UIPreviewActionItem>>>
pub unsafe fn traitOverrides( &self, ) -> Retained<ProtocolObject<dyn UITraitOverrides>>
Sourcepub unsafe fn updateTraitsIfNeeded(&self)
pub unsafe fn updateTraitsIfNeeded(&self)
Forces an immediate trait update for this view controller and its view, including any view controllers and views in this subtree. Any trait change callbacks are sent synchronously.
pub unsafe fn preferredContainerBackgroundStyle( &self, ) -> UIContainerBackgroundStyle
pub unsafe fn childViewControllerForPreferredContainerBackgroundStyle( &self, ) -> Option<Retained<UIViewController>>
pub unsafe fn setNeedsUpdateOfPreferredContainerBackgroundStyle(&self)
Methods from Deref<Target = UIResponder>§
pub unsafe fn nextResponder(&self) -> Option<Retained<UIResponder>>
pub unsafe fn canBecomeFirstResponder(&self) -> bool
pub unsafe fn becomeFirstResponder(&self) -> bool
pub unsafe fn canResignFirstResponder(&self) -> bool
pub unsafe fn resignFirstResponder(&self) -> bool
pub unsafe fn isFirstResponder(&self) -> bool
pub unsafe fn canPerformAction_withSender( &self, action: Sel, sender: Option<&AnyObject>, ) -> bool
pub unsafe fn targetForAction_withSender( &self, action: Sel, sender: Option<&AnyObject>, ) -> Option<Retained<AnyObject>>
pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>
pub unsafe fn editingInteractionConfiguration( &self, ) -> UIEditingInteractionConfiguration
pub unsafe fn inputView(&self) -> Option<Retained<UIView>>
pub unsafe fn inputAccessoryView(&self) -> Option<Retained<UIView>>
pub unsafe fn textInputContextIdentifier(&self) -> Option<Retained<NSString>>
pub unsafe fn reloadInputViews(&self)
pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>
Sourcepub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
Setter for userActivity.
pub unsafe fn updateUserActivityState(&self, activity: &NSUserActivity)
pub unsafe fn restoreUserActivityState(&self, activity: &NSUserActivity)
pub unsafe fn captureTextFromCamera(&self, sender: Option<&AnyObject>)
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 TVDigitEntryViewController
impl AsRef<AnyObject> for TVDigitEntryViewController
Source§impl AsRef<NSObject> for TVDigitEntryViewController
impl AsRef<NSObject> for TVDigitEntryViewController
Source§impl AsRef<UIResponder> for TVDigitEntryViewController
impl AsRef<UIResponder> for TVDigitEntryViewController
Source§fn as_ref(&self) -> &UIResponder
fn as_ref(&self) -> &UIResponder
Source§impl AsRef<UIViewController> for TVDigitEntryViewController
impl AsRef<UIViewController> for TVDigitEntryViewController
Source§fn as_ref(&self) -> &UIViewController
fn as_ref(&self) -> &UIViewController
Source§impl Borrow<AnyObject> for TVDigitEntryViewController
impl Borrow<AnyObject> for TVDigitEntryViewController
Source§impl Borrow<NSObject> for TVDigitEntryViewController
impl Borrow<NSObject> for TVDigitEntryViewController
Source§impl Borrow<UIResponder> for TVDigitEntryViewController
impl Borrow<UIResponder> for TVDigitEntryViewController
Source§fn borrow(&self) -> &UIResponder
fn borrow(&self) -> &UIResponder
Source§impl Borrow<UIViewController> for TVDigitEntryViewController
impl Borrow<UIViewController> for TVDigitEntryViewController
Source§fn borrow(&self) -> &UIViewController
fn borrow(&self) -> &UIViewController
Source§impl ClassType for TVDigitEntryViewController
impl ClassType for TVDigitEntryViewController
Source§const NAME: &'static str = "TVDigitEntryViewController"
const NAME: &'static str = "TVDigitEntryViewController"
Source§type Super = UIViewController
type Super = UIViewController
Source§type ThreadKind = <<TVDigitEntryViewController as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<TVDigitEntryViewController as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for TVDigitEntryViewController
impl Debug for TVDigitEntryViewController
Source§impl Deref for TVDigitEntryViewController
impl Deref for TVDigitEntryViewController
Source§impl Hash for TVDigitEntryViewController
impl Hash for TVDigitEntryViewController
Source§impl Message for TVDigitEntryViewController
impl Message for TVDigitEntryViewController
Source§impl NSObjectProtocol for TVDigitEntryViewController
impl NSObjectProtocol for TVDigitEntryViewController
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_refSource§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl RefEncode for TVDigitEntryViewController
impl RefEncode for TVDigitEntryViewController
Source§const ENCODING_REF: Encoding = <UIViewController as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <UIViewController as ::objc2::RefEncode>::ENCODING_REF
Source§impl UIContentContainer for TVDigitEntryViewController
impl UIContentContainer for TVDigitEntryViewController
unsafe fn preferredContentSize(&self) -> CGSize
unsafe fn preferredContentSizeDidChangeForChildContentContainer( &self, container: &ProtocolObject<dyn UIContentContainer>, )
unsafe fn systemLayoutFittingSizeDidChangeForChildContentContainer( &self, container: &ProtocolObject<dyn UIContentContainer>, )
unsafe fn sizeForChildContentContainer_withParentContainerSize( &self, container: &ProtocolObject<dyn UIContentContainer>, parent_size: CGSize, ) -> CGSize
Source§impl UIFocusEnvironment for TVDigitEntryViewController
impl UIFocusEnvironment for TVDigitEntryViewController
Source§unsafe fn preferredFocusEnvironments(
&self,
) -> Retained<NSArray<ProtocolObject<dyn UIFocusEnvironment>>>
unsafe fn preferredFocusEnvironments( &self, ) -> Retained<NSArray<ProtocolObject<dyn UIFocusEnvironment>>>
Source§unsafe fn parentFocusEnvironment(
&self,
) -> Option<Retained<ProtocolObject<dyn UIFocusEnvironment>>>
unsafe fn parentFocusEnvironment( &self, ) -> Option<Retained<ProtocolObject<dyn UIFocusEnvironment>>>
Source§unsafe fn focusItemContainer(
&self,
) -> Option<Retained<ProtocolObject<dyn UIFocusItemContainer>>>
unsafe fn focusItemContainer( &self, ) -> Option<Retained<ProtocolObject<dyn UIFocusItemContainer>>>
Source§unsafe fn setNeedsFocusUpdate(&self)
unsafe fn setNeedsFocusUpdate(&self)
[[UIFocusSystem focusSystemForEnvironment:self] requestFocusUpdateToEnvironment:self];Source§unsafe fn updateFocusIfNeeded(&self)
unsafe fn updateFocusIfNeeded(&self)
[[UIFocusSystem focusSystemForEnvironment:self] updateFocusIfNeeded];.Source§unsafe fn shouldUpdateFocusInContext(
&self,
context: &UIFocusUpdateContext,
) -> bool
unsafe fn shouldUpdateFocusInContext( &self, context: &UIFocusUpdateContext, ) -> bool
Source§unsafe fn soundIdentifierForFocusUpdateInContext(
&self,
context: &UIFocusUpdateContext,
) -> Option<Retained<NSString>>
unsafe fn soundIdentifierForFocusUpdateInContext( &self, context: &UIFocusUpdateContext, ) -> Option<Retained<NSString>>
Source§impl UIResponderStandardEditActions for TVDigitEntryViewController
impl UIResponderStandardEditActions for TVDigitEntryViewController
unsafe fn cut(&self, sender: Option<&AnyObject>)
unsafe fn copy(&self, sender: Option<&AnyObject>)
unsafe fn paste(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndMatchStyle(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndGo(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndSearch(&self, sender: Option<&AnyObject>)
unsafe fn select(&self, sender: Option<&AnyObject>)
unsafe fn selectAll(&self, sender: Option<&AnyObject>)
unsafe fn delete(&self, sender: Option<&AnyObject>)
unsafe fn makeTextWritingDirectionLeftToRight(&self, sender: Option<&AnyObject>)
unsafe fn makeTextWritingDirectionRightToLeft(&self, sender: Option<&AnyObject>)
unsafe fn toggleBoldface(&self, sender: Option<&AnyObject>)
unsafe fn toggleItalics(&self, sender: Option<&AnyObject>)
unsafe fn toggleUnderline(&self, sender: Option<&AnyObject>)
unsafe fn increaseSize(&self, sender: Option<&AnyObject>)
unsafe fn decreaseSize(&self, sender: Option<&AnyObject>)
unsafe fn find(&self, sender: Option<&AnyObject>)
unsafe fn findAndReplace(&self, sender: Option<&AnyObject>)
unsafe fn findNext(&self, sender: Option<&AnyObject>)
unsafe fn findPrevious(&self, sender: Option<&AnyObject>)
unsafe fn useSelectionForFind(&self, sender: Option<&AnyObject>)
unsafe fn print(&self, sender: Option<&AnyObject>)
unsafe fn rename(&self, sender: Option<&AnyObject>)
unsafe fn duplicate(&self, sender: Option<&AnyObject>)
unsafe fn move(&self, sender: Option<&AnyObject>)
unsafe fn export(&self, sender: Option<&AnyObject>)
unsafe fn showWritingTools(&self, sender: &AnyObject)
Source§impl UITraitEnvironment for TVDigitEntryViewController
impl UITraitEnvironment for TVDigitEntryViewController
fn traitCollection(&self) -> Retained<UITraitCollection>
Source§unsafe fn traitCollectionDidChange(
&self,
previous_trait_collection: Option<&UITraitCollection>,
)
unsafe fn traitCollectionDidChange( &self, previous_trait_collection: Option<&UITraitCollection>, )
impl DowncastTarget for TVDigitEntryViewController
impl Eq for TVDigitEntryViewController
impl UIAppearanceContainer for TVDigitEntryViewController
Auto Trait Implementations§
impl !Freeze for TVDigitEntryViewController
impl !RefUnwindSafe for TVDigitEntryViewController
impl !Send for TVDigitEntryViewController
impl !Sync for TVDigitEntryViewController
impl !Unpin for TVDigitEntryViewController
impl !UnwindSafe for TVDigitEntryViewController
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
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker from the main-thread-only object. Read more