From 3bb4dadc3a2af94046ef941a98707f79461f2eba Mon Sep 17 00:00:00 2001 From: extrawurst Date: Wed, 10 Apr 2024 14:59:07 +0200 Subject: [PATCH] fix ios impl crashing --- src/ios.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ios.rs b/src/ios.rs index 70fb08c..1767b14 100644 --- a/src/ios.rs +++ b/src/ios.rs @@ -23,15 +23,20 @@ pub(super) fn open_browser_internal( "UIApplication is null, can't open url", )); } - let url_cstr = std::ffi::CString::new(url).unwrap(); + + let url_cstr = std::ffi::CString::new(url)?; + // Create ns string class from our string let url_string: *mut Object = msg_send![class!(NSString), stringWithUTF8String: url_cstr]; // Create NSURL object with given string let url_object: *mut Object = msg_send![class!(NSURL), URLWithString: url_string]; // No completion handler - let null_ptr = std::ptr::null_mut::(); + let nil: *mut Object = ::core::ptr::null_mut(); + // empty options dictionary + let no_options: *mut Object = msg_send![class!(NSDictionary), new]; + // Open url - let () = msg_send![app, openURL: url_object options: {} completionHandler: null_ptr]; + let () = msg_send![app, openURL:url_object options:no_options completionHandler:nil]; Ok(()) } }