pub fn preferred_format(&self, formats: &[FormatId]) -> Option<FormatId> {
        unsafe {
            let pasteboard: id = msg_send![class!(NSPasteboard), generalPasteboard];
            let nsstrings = formats
                .iter()
                .map(|s| util::make_nsstring(s))
                .collect::<Vec<_>>();
            let array = NSArray::arrayWithObjects(nil, &nsstrings);
            let available: id = msg_send![pasteboard, availableTypeFromArray: array];
            if available.is_null() {
                None
            } else {
                let idx: NSUInteger = msg_send![array, indexOfObject: available];
                let idx = idx as usize;
                if idx > formats.len() {
                    tracing::error!("clipboard object not found");
                    None
                } else {
                    Some(formats[idx])
                }
            }
        }
    }
/// Given a list of supported clipboard types, returns the supported type which has
/// highest priority on the system clipboard, or `None` if no types are supported.
Given a list of supported clipboard types, returns the supported type which has
highest priority on the system clipboard, or `None` if no types are supported.
Given a list of supported clipboard types returns the supported type which has highest priority on the system clipboard or ` None ` if no types are supported .
pub fn preferred_format(&self, formats: &[FormatId]) -> Option<FormatId> {
        unsafe {
            let pasteboard: id = msg_send![class!(NSPasteboard), generalPasteboard];
            let nsstrings = formats
                .iter()
                .map(|s| util::make_nsstring(s))
                .collect::<Vec<_>>();
            let array = NSArray::arrayWithObjects(nil, &nsstrings);
            let available: id = msg_send![pasteboard, availableTypeFromArray: array];
            if available.is_null() {
                None
            } else {
                let idx: NSUInteger = msg_send![array, indexOfObject: available];
                let idx = idx as usize;
                if idx > formats.len() {
                    tracing::error!("clipboard object not found");
                    None
                } else {
                    Some(formats[idx])
                }
            }
        }
    }
pub fn preferred_format ( & self , formats : & [ FormatId ] ) -> Option < FormatId > { unsafe { let pasteboard : id = msg_send ! [ class ( NSPasteboard ) generalPasteboard ] ; let nsstrings = formats . iter ( ) . map ( | s | util :: make_nsstring ( s ) ) . collect :: < Vec < _ > > ( ) ; let array = NSArray :: arrayWithObjects ( nil , & nsstrings ) ; let available : id = msg_send ! [ pasteboard availableTypeFromArray array ] ; if available . is_null ( ) { None } else { let idx : NSUInteger = msg_send ! [ array indexOfObject available ] ; let idx = idx as usize ; if idx > formats . len ( ) { tracing :: error ! ( " " ) ; None } else { Some ( formats [ idx ] ) } } } }
Given a list of supported clipboard types, returns the supported type which has
highest priority on the system clipboard, or `None` if no types are supported.
Given a list of supported clipboard types returns the supported type which has highest priority on the system clipboard or ` None ` if no types are supported .
&self
formats
&[FormatId]
&self
formats
&[FormatId]