Use a bit less unsafe on iOS (#2643)
* Use a bit less `unsafe` on iOS I did test this in XCode 11.3's "Debug View Heirarchy", the NSStringRust problem is no longer applicable (likely because Rust got better at emitting correct debug info). * Avoid using `id` on iOS
This commit is contained in:
parent
0f2fbe373b
commit
a82f66826b
8 changed files with 51 additions and 100 deletions
|
|
@ -2,6 +2,10 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use std::os::raw::{c_char, c_int};
|
||||
|
||||
use objc2::foundation::NSString;
|
||||
|
||||
mod application;
|
||||
mod coordinate_space;
|
||||
mod device;
|
||||
|
|
@ -28,3 +32,13 @@ pub(crate) use self::trait_collection::{UIForceTouchCapability, UITraitCollectio
|
|||
pub(crate) use self::view::{UIEdgeInsets, UIView};
|
||||
pub(crate) use self::view_controller::{UIInterfaceOrientationMask, UIViewController};
|
||||
pub(crate) use self::window::UIWindow;
|
||||
|
||||
#[link(name = "UIKit", kind = "framework")]
|
||||
extern "C" {
|
||||
pub fn UIApplicationMain(
|
||||
argc: c_int,
|
||||
argv: *const c_char,
|
||||
principalClassName: Option<&NSString>,
|
||||
delegateClassName: Option<&NSString>,
|
||||
) -> c_int;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use objc2::encode::{Encode, Encoding};
|
||||
use objc2::foundation::{NSObject, NSUInteger};
|
||||
use objc2::{extern_class, extern_methods, ClassType};
|
||||
use objc2::rc::{Id, Shared};
|
||||
use objc2::{extern_class, extern_methods, msg_send_id, ClassType};
|
||||
|
||||
use super::{UIResponder, UIView};
|
||||
|
||||
|
|
@ -28,6 +29,10 @@ extern_methods!(
|
|||
#[sel(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]
|
||||
pub fn setNeedsUpdateOfScreenEdgesDeferringSystemGestures(&self);
|
||||
|
||||
pub fn view(&self) -> Option<Id<UIView, Shared>> {
|
||||
unsafe { msg_send_id![self, view] }
|
||||
}
|
||||
|
||||
#[sel(setView:)]
|
||||
pub fn setView(&self, view: Option<&UIView>);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue