rust_macios/appkit/
ns_storyboard.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    foundation::NSBundle,
5    object,
6    objective_c_runtime::{
7        id, nil,
8        traits::{FromId, PNSObject},
9    },
10};
11
12use super::NSStoryboardName;
13
14object! {
15    /// An encapsulation of the design-time view controller and window controller graph represented in an Interface Builder storyboard resource file.
16    unsafe pub struct NSStoryboard
17}
18
19impl INSStoryboard for NSStoryboard {}
20
21/// An encapsulation of the design-time view controller and window controller graph represented in an Interface Builder storyboard resource file.
22pub trait INSStoryboard: PNSObject {
23    /// Creates a storyboard based on the named storyboard file in the specified bundle.
24    fn tm_storyboard_with_name_bundle(name: NSStoryboardName, bundle: Option<NSBundle>) -> Self
25    where
26        Self: Sized + FromId,
27    {
28        unsafe {
29            Self::from_id(
30                msg_send![Self::m_class(), storyboardWithName: name bundle: match bundle {
31                    Some(val) => val.m_self(),
32                    None => nil
33                }],
34            )
35        }
36    }
37
38    /// The app's main storyboard.
39    fn tp_main_storyboard() -> NSStoryboard {
40        unsafe { NSStoryboard::from_id(msg_send![Self::m_class(), mainStoryboard]) }
41    }
42
43    /* Loading the Initial View Controller
44     */
45
46    /// Creates the initial view controller or window controller from a storyboard.
47    fn im_instantiate_initial_controller(&self) -> id {
48        unsafe { msg_send![Self::m_class(), instantiateInitialController] }
49    }
50}