pub struct CPInterfaceController { /* private fields */ }CPInterfaceController only.Expand description
Implementations§
Source§impl CPInterfaceController
impl CPInterfaceController
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>
Sourcepub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn CPInterfaceControllerDelegate>>>
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn CPInterfaceControllerDelegate>>>
The delegate for this interface controller.
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CPInterfaceControllerDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn CPInterfaceControllerDelegate>>, )
Setter for delegate.
This is a weak property.
Sourcepub unsafe fn prefersDarkUserInterfaceStyle(&self) -> bool
pub unsafe fn prefersDarkUserInterfaceStyle(&self) -> bool
Set the preferred interface style to UIUserInterfaceStyleDark for all templates. Set this value to YES prior to setting a root template or pushing any templates for first appearance to have style UIUserInterfaceStyleDark. The default value is NO which will allow templates to change between light and dark styles.
Sourcepub unsafe fn setPrefersDarkUserInterfaceStyle(
&self,
prefers_dark_user_interface_style: bool,
)
pub unsafe fn setPrefersDarkUserInterfaceStyle( &self, prefers_dark_user_interface_style: bool, )
Setter for prefersDarkUserInterfaceStyle.
Sourcepub unsafe fn setRootTemplate_animated_completion(
&self,
root_template: &CPTemplate,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate features CPTemplate and block2 only.
pub unsafe fn setRootTemplate_animated_completion( &self, root_template: &CPTemplate, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
CPTemplate and block2 only.Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored. If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
The completion block will be called after the template has been presented. If the template was presented successfully,
the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
NSErrorwill be provided describing the failure.
Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
Sourcepub unsafe fn pushTemplate_animated_completion(
&self,
template_to_push: &CPTemplate,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate features CPTemplate and block2 only.
pub unsafe fn pushTemplate_animated_completion( &self, template_to_push: &CPTemplate, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
CPTemplate and block2 only.Push a new template onto the template navigation hierarchy, showing it immediately.
The completion block will be called after the template has been presented. If the template was presented successfully,
the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
NSErrorwill be provided describing the failure.
Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
Sourcepub unsafe fn popTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn popTemplateAnimated_completion( &self, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
block2 only.Pop back a single level in the template navigation hierarchy. The completion block will be called after the pop completes. The success parameter in the completion block indicates if any template was popped.
Sourcepub unsafe fn popToRootTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn popToRootTemplateAnimated_completion( &self, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
block2 only.Pop back to the first template in the template navigation hierarchy. The completion block will be called after the pop completes. The success parameter in the completion block indicates if any templates were popped.
Sourcepub unsafe fn popToTemplate_animated_completion(
&self,
target_template: &CPTemplate,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate features CPTemplate and block2 only.
pub unsafe fn popToTemplate_animated_completion( &self, target_template: &CPTemplate, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
CPTemplate and block2 only.Pop back to a specified template.
targetTemplate must exist in the current template navigation hierarchy.
The completion block will be called after the pop completes. If the specified template does not exist in the template stack, the completion block will be called with a success parameter of NO and a non-nil NSError.
Sourcepub unsafe fn presentTemplate_animated_completion(
&self,
template_to_present: &CPTemplate,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate features CPTemplate and block2 only.
pub unsafe fn presentTemplate_animated_completion( &self, template_to_present: &CPTemplate, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
CPTemplate and block2 only.Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
Note: Supported template types:
CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplateThe completion block will be called after the template has been presented. If the template was presented successfully,
the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
NSErrorwill be provided describing the failure.
Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
Sourcepub unsafe fn dismissTemplateAnimated_completion(
&self,
animated: bool,
completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn dismissTemplateAnimated_completion( &self, animated: bool, completion: Option<&DynBlock<dyn Fn(Bool, *mut NSError)>>, )
block2 only.Dismiss the current modally-presented template, optionally animating the dismissal.
Note: If there is no current modally-presented template, this method will have no effect.
The completion block will be called after the template has been dismissed. If the template was dismissed successfully,
the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
NSErrorwill be provided describing the failure.
Sourcepub unsafe fn presentedTemplate(&self) -> Option<Retained<CPTemplate>>
Available on crate feature CPTemplate only.
pub unsafe fn presentedTemplate(&self) -> Option<Retained<CPTemplate>>
CPTemplate only.The current modally-presented template.
Warning: Reading this property may synchronously perform an IPC call to retrieve the current presented template.
Sourcepub unsafe fn rootTemplate(&self) -> Retained<CPTemplate>
Available on crate feature CPTemplate only.
pub unsafe fn rootTemplate(&self) -> Retained<CPTemplate>
CPTemplate only.Returns the root template.
Sourcepub unsafe fn topTemplate(&self) -> Option<Retained<CPTemplate>>
Available on crate feature CPTemplate only.
pub unsafe fn topTemplate(&self) -> Option<Retained<CPTemplate>>
CPTemplate only.The top template in the navigation hierarchy.
Warning: Reading this property may synchronously perform an IPC call to retrieve the current top-most template.
Sourcepub unsafe fn templates(&self) -> Retained<NSArray<CPTemplate>>
Available on crate feature CPTemplate only.
pub unsafe fn templates(&self) -> Retained<NSArray<CPTemplate>>
CPTemplate only.The current stack of templates in the navigation hierarchy.
Warning: Reading this property may synchronously perform an IPC call to retrieve the current stack of templates.
Sourcepub unsafe fn carTraitCollection(&self) -> Retained<UITraitCollection>
Available on crate feature objc2-ui-kit only.
pub unsafe fn carTraitCollection(&self) -> Retained<UITraitCollection>
objc2-ui-kit only.The trait collection for the car’s primary screen.
Your app should use this trait collection when deriving metrics, like screen scale, for
your templates. For example, images you display in any template should be sized to a
display scale matching the scale of the
carTraitCollection,not the scale of the
iOS device’s main screen.
Sourcepub unsafe fn setRootTemplate_animated(
&self,
root_template: &CPTemplate,
animated: bool,
)
👎DeprecatedAvailable on crate feature CPTemplate only.
pub unsafe fn setRootTemplate_animated( &self, root_template: &CPTemplate, animated: bool, )
CPTemplate only.Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored. If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
Sourcepub unsafe fn pushTemplate_animated(
&self,
template_to_push: &CPTemplate,
animated: bool,
)
👎DeprecatedAvailable on crate feature CPTemplate only.
pub unsafe fn pushTemplate_animated( &self, template_to_push: &CPTemplate, animated: bool, )
CPTemplate only.Push a new template onto the template navigation hierarchy, showing it immediately.
Sourcepub unsafe fn popTemplateAnimated(&self, animated: bool)
👎Deprecated
pub unsafe fn popTemplateAnimated(&self, animated: bool)
Pop back a single level in the template navigation hierarchy.
Sourcepub unsafe fn popToRootTemplateAnimated(&self, animated: bool)
👎Deprecated
pub unsafe fn popToRootTemplateAnimated(&self, animated: bool)
Pop back to the first template in the template navigation hierarchy.
Sourcepub unsafe fn popToTemplate_animated(
&self,
target_template: &CPTemplate,
animated: bool,
)
👎DeprecatedAvailable on crate feature CPTemplate only.
pub unsafe fn popToTemplate_animated( &self, target_template: &CPTemplate, animated: bool, )
CPTemplate only.Pop back to a specified template.
targetTemplate must exist in the current template navigation hierarchy.
Sourcepub unsafe fn presentTemplate_animated(
&self,
template_to_present: &CPTemplate,
animated: bool,
)
👎DeprecatedAvailable on crate feature CPTemplate only.
pub unsafe fn presentTemplate_animated( &self, template_to_present: &CPTemplate, animated: bool, )
CPTemplate only.Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
Note: Supported template types:
CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplate
Sourcepub unsafe fn dismissTemplateAnimated(&self, animated: bool)
👎Deprecated
pub unsafe fn dismissTemplateAnimated(&self, animated: bool)
Dismiss the current modally-presented template, optionally animating the dismissal.
Note: If there is no current modally-presented template, this method will have no effect.
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 CPInterfaceController
impl AsRef<AnyObject> for CPInterfaceController
Source§impl AsRef<NSObject> for CPInterfaceController
impl AsRef<NSObject> for CPInterfaceController
Source§impl Borrow<AnyObject> for CPInterfaceController
impl Borrow<AnyObject> for CPInterfaceController
Source§impl Borrow<NSObject> for CPInterfaceController
impl Borrow<NSObject> for CPInterfaceController
Source§impl ClassType for CPInterfaceController
impl ClassType for CPInterfaceController
Source§const NAME: &'static str = "CPInterfaceController"
const NAME: &'static str = "CPInterfaceController"
Source§type ThreadKind = dyn MainThreadOnly
type ThreadKind = dyn MainThreadOnly
Source§impl Debug for CPInterfaceController
impl Debug for CPInterfaceController
Source§impl Deref for CPInterfaceController
impl Deref for CPInterfaceController
Source§impl Hash for CPInterfaceController
impl Hash for CPInterfaceController
Source§impl Message for CPInterfaceController
impl Message for CPInterfaceController
Source§impl NSObjectProtocol for CPInterfaceController
impl NSObjectProtocol for CPInterfaceController
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 PartialEq for CPInterfaceController
impl PartialEq for CPInterfaceController
Source§impl RefEncode for CPInterfaceController
impl RefEncode for CPInterfaceController
Source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for CPInterfaceController
impl Eq for CPInterfaceController
Auto Trait Implementations§
impl !Freeze for CPInterfaceController
impl !RefUnwindSafe for CPInterfaceController
impl !Send for CPInterfaceController
impl !Sync for CPInterfaceController
impl !Unpin for CPInterfaceController
impl !UnwindSafe for CPInterfaceController
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