Closed eks5115 closed 3 weeks ago
It kinda depends on the method you're calling; if you can use a generated method in icrate
, you should do that, then you can just pass None
to methods that expect nil
.
If what you need is not in icrate
, then I suggest you make a helper function for your msg_send!
call, so that you can ensure that the types are correct, something like the following (again, exact signature depends on the method you're calling):
fn call_with_param1_param2(obj: &NSObject, param1: MyParam, param2: Option<&NSObject>) {
unsafe { msg_send![obj, param1: param1, param2: param2] }
}
call_with_param1_param2(&obj, value, None);
If you want to avoid all of this, you can use the following to get the a NULL
pointer that you can use in message sends.
use std::ptr;
use objc2::runtime::AnyObject;
let nil: *const AnyObject = ptr::null();
Thank you very much. All of these methods will work
how to do send nil ?
example: msg_send![&obj, param1: value, param2: nil]