Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing descriptorType at NSAppleEventDescriptor #590

Open
mdevils opened this issue Mar 15, 2024 · 4 comments
Open

Missing descriptorType at NSAppleEventDescriptor #590

mdevils opened this issue Mar 15, 2024 · 4 comments
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working

Comments

@mdevils
Copy link

mdevils commented Mar 15, 2024

Hello!

I wanted to access descriptorType at NSAppleEventDescriptor in order to understand the type of the descriptor, but couldn't find the corresponding field in the generated icrate package. Is there a way to access that field for me?

@madsmtm madsmtm added bug Something isn't working A-framework Affects the framework crates and the translator for them labels Mar 15, 2024
@madsmtm
Copy link
Owner

madsmtm commented Mar 15, 2024

The reason it's not present is that the type of that field is DescType, which comes from the CoreServices framework, which is not yet mapped.

You can do the following in the meantime. Depending on your needs, you might have to pull in the core-services crate too.

use icrate::Foundation::NSAppleEventDescriptor;
use objc2::msg_send;

use core_services::DescType; // If using `core-services`
type DescType = u32; // If not using `core-services`

pub fn get_descriptor_type(desc: &NSAppleEventDescriptor) -> DescType {
    unsafe { msg_send![desc, descriptorType] }
}

@mdevils
Copy link
Author

mdevils commented Mar 16, 2024

@madsmtm thank you for your help. Could you please advice me, how do I call this method?

[NSAppleEventDescriptor init(string:)]

Info: https://developer.apple.com/documentation/foundation/nsappleeventdescriptor/1415227-init

@madsmtm
Copy link
Owner

madsmtm commented Mar 17, 2024

First, have a look at the Objective-C documentation instead:
https://developer.apple.com/documentation/foundation/nsappleeventdescriptor/1415227-descriptorwithstring?language=objc

Now you can do roughly what I did above, except using msg_send_id! as this function is returning an object:

pub fn descriptor_with_string(string: &NSString) -> Id<NSAppleEventDescriptor> {
    unsafe { msg_send_id![NSAppleEventDescriptor::class(), descriptorWithString: string] }
}

@mdevils
Copy link
Author

mdevils commented Mar 19, 2024

@madsmtm thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants