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:
Mads Marquart 2023-01-23 00:01:45 +01:00 committed by GitHub
parent 0f2fbe373b
commit a82f66826b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 100 deletions

View file

@ -14,13 +14,14 @@ use core_foundation::runloop::{
CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext, CFRunLoopSourceCreate,
CFRunLoopSourceInvalidate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
};
use objc2::foundation::MainThreadMarker;
use objc2::foundation::{MainThreadMarker, NSString};
use objc2::rc::{Id, Shared};
use objc2::ClassType;
use raw_window_handle::{RawDisplayHandle, UiKitDisplayHandle};
use super::uikit::{UIApplication, UIDevice, UIScreen};
use super::uikit::{UIApplication, UIApplicationMain, UIDevice, UIScreen};
use super::view::WinitUIWindow;
use super::{app_state, monitor, view, MonitorHandle};
use crate::{
dpi::LogicalSize,
event::Event,
@ -30,12 +31,6 @@ use crate::{
platform::ios::Idiom,
};
use crate::platform_impl::platform::{
app_state,
ffi::{nil, NSStringRust, UIApplicationMain},
monitor, view, MonitorHandle,
};
#[derive(Debug)]
pub(crate) enum EventWrapper {
StaticEvent(Event<'static, Never>),
@ -132,8 +127,8 @@ impl<T: 'static> EventLoop<T> {
UIApplicationMain(
0,
ptr::null(),
nil,
NSStringRust::alloc(nil).init_str("WinitApplicationDelegate"),
None,
Some(&NSString::from_str("WinitApplicationDelegate")),
);
unreachable!()
}