-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I'm modifying a library that uses objc. I need to import a constant NSString. I tried const* NSString and Id<NSString> but rustc warned me that these are not "FFI safe". This, however, appears to work:
// required to bring NSPasteboard into the path of the class-resolver
#[link(name = "AppKit", kind = "framework")]
extern "C" {
// NSString
static NSPasteboardURLReadingFileURLsOnlyKey: &'static Object;
}
Here is the usage:
let ns_dict = class!(NSDictionary);
let ns_number = class!(NSNumber);
let options: Id<NSDictionary<NSObject, NSObject>> = unsafe {
let obj: Id<NSObject> = msg_send![ns_number, numberWithBool: objc::runtime::YES];
msg_send![ns_dict, dictionaryWithObject:obj forKey: NSPasteboardURLReadingFileURLsOnlyKey]
};
Is this correct, safe and idiomatic?
Metadata
Metadata
Assignees
Labels
No labels