rust_macios/contacts/
cn_phone_number.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::NSString,
5 object,
6 objective_c_runtime::{
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10};
11
12object! {
13 unsafe pub struct CNPhoneNumber;
15}
16
17#[interface_impl(NSObject)]
18impl CNPhoneNumber {
19 #[method]
24 pub fn init_with_string_value(&mut self, phone_number: NSString) -> Self
25 where
26 Self: Sized + FromId,
27 {
28 unsafe { Self::from_id(msg_send![self.m_self(), initWithString: phone_number]) }
29 }
30
31 #[method]
33 pub fn phone_number_with_string_value(phone_number: NSString) -> Self
34 where
35 Self: Sized + FromId,
36 {
37 unsafe {
38 Self::from_id(msg_send![
39 Self::m_class(),
40 phoneNumberWithString: phone_number
41 ])
42 }
43 }
44
45 #[property]
50 pub fn string_value(&self) -> NSString {
51 unsafe { NSString::from_id(msg_send![self.m_self(), stringValue]) }
52 }
53}