-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesbugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
when trying to create a UIDropInteractionDelegate like this:
define_class!(
#[unsafe(super = NSObject)]
#[thread_kind = MainThreadOnly]
#[name = "Delegate"]
struct Delegate;
unsafe impl NSObjectProtocol for Delegate {}
unsafe impl UIDropInteractionDelegate for Delegate {
#[unsafe(method(dropInteraction:sessionDidUpdate:))]
unsafe fn session_did_update(
&self,
interaction: &UIDropInteraction,
session: &ProtocolObject<dyn UIDropSession>,
) -> Retained<UIDropProposal> {
let mtm = MainThreadMarker::new().unwrap();
let instance = UIDropProposal::alloc(mtm);
UIDropProposal::initWithDropOperation(instance, UIDropOperation::Copy)
}
}
the compiler tells me:
36 | / define_class!(
37 | | #[unsafe(super = NSObject)]
38 | | #[thread_kind = MainThreadOnly]
39 | | #[name = "Delegate"]
... |
110 | | );
| |_^ the trait `Encode` is not implemented for `Retained<UIDropProposal>`
implement all other methods seems to work fine (but most don't return anything).
the issue can be worked around by returning a raw pointer:
#[unsafe(method(dropInteraction:sessionDidUpdate:))]
unsafe fn session_did_update(
&self,
interaction: &UIDropInteraction,
session: &ProtocolObject<dyn UIDropSession>,
) -> *mut UIDropProposal {
let mtm = MainThreadMarker::new().unwrap();
let instance = UIDropProposal::alloc(mtm);
Retained::into_raw(UIDropProposal::initWithDropOperation(instance, UIDropOperation::Copy))
}
Metadata
Metadata
Assignees
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesbugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested