use objc::{msg_send, sel, sel_impl};
use crate::{
foundation::{NSArray, NSPredicate},
object,
objective_c_runtime::{id, macros::interface_impl, traits::FromId},
utils::to_bool,
};
use super::{CNContactSortOrder, ICNFetchRequest};
object! {
unsafe pub struct CNContactFetchRequest;
}
impl ICNFetchRequest for CNContactFetchRequest {}
#[interface_impl(CNFetchRequest)]
impl CNContactFetchRequest {
#[method]
pub fn init_with_keys_to_fetch(&self, keys: NSArray<id>) -> Self
where
Self: Sized + FromId,
{
unsafe { Self::from_id(msg_send![self.m_self(), initWithKeysToFetch: keys]) }
}
#[property]
pub fn predicate(&self) -> NSPredicate {
unsafe { NSPredicate::from_id(msg_send![self.m_self(), predicate]) }
}
#[property]
pub fn set_predicate(&mut self, predicate: NSPredicate) {
unsafe { msg_send![self.m_self(), setPredicate: predicate] }
}
#[property]
pub fn mutable_objects(&self) -> bool {
unsafe { to_bool(msg_send![self.m_self(), mutableObjects]) }
}
#[property]
pub fn set_mutable_objects(&mut self, mutable_objects: bool) {
unsafe { msg_send![self.m_self(), setMutableObjects: mutable_objects] }
}
#[property]
pub fn unify_results(&self) -> bool {
unsafe { to_bool(msg_send![self.m_self(), unifyResults]) }
}
#[property]
pub fn set_unify_results(&mut self, unify_results: bool) {
unsafe { msg_send![self.m_self(), setUnifyResults: unify_results] }
}
#[property]
pub fn sort_order(&self) -> CNContactSortOrder {
unsafe { msg_send![self.m_self(), sortOrder] }
}
#[property]
pub fn keys_to_fetch(&self) -> NSArray<id> {
unsafe { NSArray::from_id(msg_send![self.m_self(), keysToFetch]) }
}
#[property]
pub fn set_keys_to_fetch(&mut self, keys_to_fetch: NSArray<id>) {
unsafe { msg_send![self.m_self(), setKeysToFetch: keys_to_fetch] }
}
}