RetroArch/pkg/apple/CocoaView+Utilities.swift
LibretroAdmin 18c85b5ccd Cleanups -
* Less string copies
* Some general cleanups
* Add extra param to runloop_message_queue_push so we can pass size_t
of the message
* Consistent conventions for local variable usage for certain things
2024-12-27 15:13:45 +01:00

29 lines
907 B
Swift

//
// CocoaView+Utilities.swift
// RetroArchiOS
//
// Created by Yoshi Sugawara on 3/2/22.
// Copyright © 2022 RetroArch. All rights reserved.
//
extension CocoaView {
// A native swift wrapper around displaying notifications
@objc func showRetroArchNotification(
title: String? = nil,
message: String,
icon: message_queue_icon = MESSAGE_QUEUE_ICON_DEFAULT,
category: message_queue_category = MESSAGE_QUEUE_CATEGORY_INFO
) {
guard let messageCString = message.cString(using: .utf8) else { return }
let titleCString: UnsafeMutablePointer<CChar>? = {
if let title = title {
let str = title as NSString
return UnsafeMutablePointer<CChar>(mutating: str.utf8String)
}
return nil
}()
runloop_msg_queue_push(messageCString, strlen(messageCString), 1, 100, true, titleCString, icon, category)
}
}