pub struct CNMutableContact { /* private fields */ }CNContact and CNMutableContact only.Expand description
A mutable value object representing a contact.
CNMutableContact is not thread safe. If this is a mutable copy of CNContact then it will throw CNContactPropertyNotFetchedExceptionName when accessing a property that was not fetched for the CNContact.
Note: To remove properties when saving a mutable contact, set string properties and array properties to empty values. Set other properties to nil.
See also Apple’s documentation
Implementations§
Source§impl CNMutableContact
impl CNMutableContact
pub unsafe fn contactType(&self) -> CNContactType
Sourcepub unsafe fn setContactType(&self, contact_type: CNContactType)
pub unsafe fn setContactType(&self, contact_type: CNContactType)
Setter for contactType.
pub unsafe fn namePrefix(&self) -> Retained<NSString>
Sourcepub unsafe fn setNamePrefix(&self, name_prefix: &NSString)
pub unsafe fn setNamePrefix(&self, name_prefix: &NSString)
Setter for namePrefix.
This is copied when set.
pub unsafe fn givenName(&self) -> Retained<NSString>
Sourcepub unsafe fn setGivenName(&self, given_name: &NSString)
pub unsafe fn setGivenName(&self, given_name: &NSString)
pub unsafe fn middleName(&self) -> Retained<NSString>
Sourcepub unsafe fn setMiddleName(&self, middle_name: &NSString)
pub unsafe fn setMiddleName(&self, middle_name: &NSString)
Setter for middleName.
This is copied when set.
pub unsafe fn familyName(&self) -> Retained<NSString>
Sourcepub unsafe fn setFamilyName(&self, family_name: &NSString)
pub unsafe fn setFamilyName(&self, family_name: &NSString)
Setter for familyName.
This is copied when set.
pub unsafe fn previousFamilyName(&self) -> Retained<NSString>
Sourcepub unsafe fn setPreviousFamilyName(&self, previous_family_name: &NSString)
pub unsafe fn setPreviousFamilyName(&self, previous_family_name: &NSString)
Setter for previousFamilyName.
This is copied when set.
pub unsafe fn nameSuffix(&self) -> Retained<NSString>
Sourcepub unsafe fn setNameSuffix(&self, name_suffix: &NSString)
pub unsafe fn setNameSuffix(&self, name_suffix: &NSString)
Setter for nameSuffix.
This is copied when set.
pub unsafe fn nickname(&self) -> Retained<NSString>
Sourcepub unsafe fn setNickname(&self, nickname: &NSString)
pub unsafe fn setNickname(&self, nickname: &NSString)
pub unsafe fn organizationName(&self) -> Retained<NSString>
Sourcepub unsafe fn setOrganizationName(&self, organization_name: &NSString)
pub unsafe fn setOrganizationName(&self, organization_name: &NSString)
Setter for organizationName.
This is copied when set.
pub unsafe fn departmentName(&self) -> Retained<NSString>
Sourcepub unsafe fn setDepartmentName(&self, department_name: &NSString)
pub unsafe fn setDepartmentName(&self, department_name: &NSString)
Setter for departmentName.
This is copied when set.
pub unsafe fn jobTitle(&self) -> Retained<NSString>
Sourcepub unsafe fn setJobTitle(&self, job_title: &NSString)
pub unsafe fn setJobTitle(&self, job_title: &NSString)
pub unsafe fn phoneticGivenName(&self) -> Retained<NSString>
Sourcepub unsafe fn setPhoneticGivenName(&self, phonetic_given_name: &NSString)
pub unsafe fn setPhoneticGivenName(&self, phonetic_given_name: &NSString)
Setter for phoneticGivenName.
This is copied when set.
pub unsafe fn phoneticMiddleName(&self) -> Retained<NSString>
Sourcepub unsafe fn setPhoneticMiddleName(&self, phonetic_middle_name: &NSString)
pub unsafe fn setPhoneticMiddleName(&self, phonetic_middle_name: &NSString)
Setter for phoneticMiddleName.
This is copied when set.
pub unsafe fn phoneticFamilyName(&self) -> Retained<NSString>
Sourcepub unsafe fn setPhoneticFamilyName(&self, phonetic_family_name: &NSString)
pub unsafe fn setPhoneticFamilyName(&self, phonetic_family_name: &NSString)
Setter for phoneticFamilyName.
This is copied when set.
pub unsafe fn phoneticOrganizationName(&self) -> Retained<NSString>
Sourcepub unsafe fn setPhoneticOrganizationName(
&self,
phonetic_organization_name: &NSString,
)
pub unsafe fn setPhoneticOrganizationName( &self, phonetic_organization_name: &NSString, )
Setter for phoneticOrganizationName.
This is copied when set.
pub unsafe fn note(&self) -> Retained<NSString>
pub unsafe fn imageData(&self) -> Option<Retained<NSData>>
Sourcepub unsafe fn setImageData(&self, image_data: Option<&NSData>)
pub unsafe fn setImageData(&self, image_data: Option<&NSData>)
pub unsafe fn phoneNumbers( &self, ) -> Retained<NSArray<CNLabeledValue<CNPhoneNumber>>>
CNLabeledValue and CNPhoneNumber only.Sourcepub unsafe fn setPhoneNumbers(
&self,
phone_numbers: &NSArray<CNLabeledValue<CNPhoneNumber>>,
)
Available on crate features CNLabeledValue and CNPhoneNumber only.
pub unsafe fn setPhoneNumbers( &self, phone_numbers: &NSArray<CNLabeledValue<CNPhoneNumber>>, )
CNLabeledValue and CNPhoneNumber only.Setter for phoneNumbers.
This is copied when set.
pub unsafe fn emailAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<NSString>>>
CNLabeledValue only.Sourcepub unsafe fn setEmailAddresses(
&self,
email_addresses: &NSArray<CNLabeledValue<NSString>>,
)
Available on crate feature CNLabeledValue only.
pub unsafe fn setEmailAddresses( &self, email_addresses: &NSArray<CNLabeledValue<NSString>>, )
CNLabeledValue only.Setter for emailAddresses.
This is copied when set.
pub unsafe fn postalAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<CNPostalAddress>>>
CNLabeledValue and CNPostalAddress only.Sourcepub unsafe fn setPostalAddresses(
&self,
postal_addresses: &NSArray<CNLabeledValue<CNPostalAddress>>,
)
Available on crate features CNLabeledValue and CNPostalAddress only.
pub unsafe fn setPostalAddresses( &self, postal_addresses: &NSArray<CNLabeledValue<CNPostalAddress>>, )
CNLabeledValue and CNPostalAddress only.Setter for postalAddresses.
This is copied when set.
pub unsafe fn urlAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>
CNLabeledValue only.Sourcepub unsafe fn setUrlAddresses(
&self,
url_addresses: &NSArray<CNLabeledValue<NSString>>,
)
Available on crate feature CNLabeledValue only.
pub unsafe fn setUrlAddresses( &self, url_addresses: &NSArray<CNLabeledValue<NSString>>, )
CNLabeledValue only.Setter for urlAddresses.
This is copied when set.
pub unsafe fn contactRelations( &self, ) -> Retained<NSArray<CNLabeledValue<CNContactRelation>>>
CNContactRelation and CNLabeledValue only.Sourcepub unsafe fn setContactRelations(
&self,
contact_relations: &NSArray<CNLabeledValue<CNContactRelation>>,
)
Available on crate features CNContactRelation and CNLabeledValue only.
pub unsafe fn setContactRelations( &self, contact_relations: &NSArray<CNLabeledValue<CNContactRelation>>, )
CNContactRelation and CNLabeledValue only.Setter for contactRelations.
This is copied when set.
CNLabeledValue and CNSocialProfile only.Sourcepub unsafe fn setSocialProfiles(
&self,
social_profiles: &NSArray<CNLabeledValue<CNSocialProfile>>,
)
Available on crate features CNLabeledValue and CNSocialProfile only.
pub unsafe fn setSocialProfiles( &self, social_profiles: &NSArray<CNLabeledValue<CNSocialProfile>>, )
CNLabeledValue and CNSocialProfile only.Setter for socialProfiles.
This is copied when set.
pub unsafe fn instantMessageAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<CNInstantMessageAddress>>>
CNInstantMessageAddress and CNLabeledValue only.Sourcepub unsafe fn setInstantMessageAddresses(
&self,
instant_message_addresses: &NSArray<CNLabeledValue<CNInstantMessageAddress>>,
)
Available on crate features CNInstantMessageAddress and CNLabeledValue only.
pub unsafe fn setInstantMessageAddresses( &self, instant_message_addresses: &NSArray<CNLabeledValue<CNInstantMessageAddress>>, )
CNInstantMessageAddress and CNLabeledValue only.Setter for instantMessageAddresses.
This is copied when set.
Sourcepub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>
pub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>
The Gregorian birthday.
Only uses day, month and year components. Needs to have at least a day and a month.
Sourcepub unsafe fn setBirthday(&self, birthday: Option<&NSDateComponents>)
pub unsafe fn setBirthday(&self, birthday: Option<&NSDateComponents>)
Sourcepub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>
pub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>
The alternate birthday (Lunisolar).
Only uses day, month, year and calendar components. Needs to have at least a day and a month. Calendar must be Chinese, Hebrew or Islamic.
Sourcepub unsafe fn setNonGregorianBirthday(
&self,
non_gregorian_birthday: Option<&NSDateComponents>,
)
pub unsafe fn setNonGregorianBirthday( &self, non_gregorian_birthday: Option<&NSDateComponents>, )
Setter for nonGregorianBirthday.
This is copied when set.
Sourcepub unsafe fn dates(
&self,
) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>
Available on crate feature CNLabeledValue only.
pub unsafe fn dates( &self, ) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>
CNLabeledValue only.Other Gregorian dates (anniversaries, etc).
Only uses day, month and year components. Needs to have at least a day and a month.
Sourcepub unsafe fn setDates(&self, dates: &NSArray<CNLabeledValue<NSDateComponents>>)
Available on crate feature CNLabeledValue only.
pub unsafe fn setDates(&self, dates: &NSArray<CNLabeledValue<NSDateComponents>>)
CNLabeledValue only.Methods from Deref<Target = CNContact>§
Sourcepub unsafe fn identifier(&self) -> Retained<NSString>
pub unsafe fn identifier(&self) -> Retained<NSString>
The identifier is unique among contacts on the device. It can be saved and used for fetching contacts next application launch.
pub unsafe fn contactType(&self) -> CNContactType
pub unsafe fn namePrefix(&self) -> Retained<NSString>
pub unsafe fn givenName(&self) -> Retained<NSString>
pub unsafe fn middleName(&self) -> Retained<NSString>
pub unsafe fn familyName(&self) -> Retained<NSString>
pub unsafe fn previousFamilyName(&self) -> Retained<NSString>
pub unsafe fn nameSuffix(&self) -> Retained<NSString>
pub unsafe fn nickname(&self) -> Retained<NSString>
pub unsafe fn organizationName(&self) -> Retained<NSString>
pub unsafe fn departmentName(&self) -> Retained<NSString>
pub unsafe fn jobTitle(&self) -> Retained<NSString>
pub unsafe fn phoneticGivenName(&self) -> Retained<NSString>
pub unsafe fn phoneticMiddleName(&self) -> Retained<NSString>
pub unsafe fn phoneticFamilyName(&self) -> Retained<NSString>
pub unsafe fn phoneticOrganizationName(&self) -> Retained<NSString>
pub unsafe fn note(&self) -> Retained<NSString>
pub unsafe fn imageData(&self) -> Option<Retained<NSData>>
pub unsafe fn thumbnailImageData(&self) -> Option<Retained<NSData>>
pub unsafe fn imageDataAvailable(&self) -> bool
pub unsafe fn phoneNumbers( &self, ) -> Retained<NSArray<CNLabeledValue<CNPhoneNumber>>>
CNLabeledValue and CNPhoneNumber only.pub unsafe fn emailAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<NSString>>>
CNLabeledValue only.pub unsafe fn postalAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<CNPostalAddress>>>
CNLabeledValue and CNPostalAddress only.pub unsafe fn urlAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>
CNLabeledValue only.pub unsafe fn contactRelations( &self, ) -> Retained<NSArray<CNLabeledValue<CNContactRelation>>>
CNContactRelation and CNLabeledValue only.CNLabeledValue and CNSocialProfile only.pub unsafe fn instantMessageAddresses( &self, ) -> Retained<NSArray<CNLabeledValue<CNInstantMessageAddress>>>
CNInstantMessageAddress and CNLabeledValue only.Sourcepub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>
pub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>
The Gregorian birthday.
Sourcepub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>
pub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>
The alternate birthday (Lunisolar).
Sourcepub unsafe fn dates(
&self,
) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>
Available on crate feature CNLabeledValue only.
pub unsafe fn dates( &self, ) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>
CNLabeledValue only.Other Gregorian dates (anniversaries, etc).
Sourcepub unsafe fn isKeyAvailable(&self, key: &NSString) -> bool
pub unsafe fn isKeyAvailable(&self, key: &NSString) -> bool
Returns YES if the value for the specified key was fetched.
Sourcepub unsafe fn areKeysAvailable(
&self,
key_descriptors: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>,
) -> bool
pub unsafe fn areKeysAvailable( &self, key_descriptors: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>, ) -> bool
Returns YES if the values for the keys specified by all the descriptors were fetched.
Sourcepub unsafe fn isUnifiedWithContactWithIdentifier(
&self,
contact_identifier: &NSString,
) -> bool
pub unsafe fn isUnifiedWithContactWithIdentifier( &self, contact_identifier: &NSString, ) -> bool
Returns YES if the receiver was fetched as a unified contact and includes the contact having contactIdentifier in its unification
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for CNMutableContact
impl AsRef<AnyObject> for CNMutableContact
Source§impl AsRef<CNContact> for CNMutableContact
impl AsRef<CNContact> for CNMutableContact
Source§impl AsRef<CNMutableContact> for CNMutableContact
impl AsRef<CNMutableContact> for CNMutableContact
Source§impl AsRef<NSObject> for CNMutableContact
impl AsRef<NSObject> for CNMutableContact
Source§impl Borrow<AnyObject> for CNMutableContact
impl Borrow<AnyObject> for CNMutableContact
Source§impl Borrow<CNContact> for CNMutableContact
impl Borrow<CNContact> for CNMutableContact
Source§impl Borrow<NSObject> for CNMutableContact
impl Borrow<NSObject> for CNMutableContact
Source§impl ClassType for CNMutableContact
impl ClassType for CNMutableContact
Source§const NAME: &'static str = "CNMutableContact"
const NAME: &'static str = "CNMutableContact"
Source§type ThreadKind = <<CNMutableContact as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<CNMutableContact as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for CNMutableContact
impl CopyingHelper for CNMutableContact
Source§impl Debug for CNMutableContact
impl Debug for CNMutableContact
Source§impl Deref for CNMutableContact
impl Deref for CNMutableContact
Source§impl Hash for CNMutableContact
impl Hash for CNMutableContact
Source§impl Message for CNMutableContact
impl Message for CNMutableContact
Source§impl MutableCopyingHelper for CNMutableContact
impl MutableCopyingHelper for CNMutableContact
Source§type Result = CNMutableContact
type Result = CNMutableContact
Self if the type has no
mutable counterpart. Read moreSource§impl NSCopying for CNMutableContact
impl NSCopying for CNMutableContact
Source§impl NSMutableCopying for CNMutableContact
impl NSMutableCopying for CNMutableContact
Source§impl NSObjectProtocol for CNMutableContact
impl NSObjectProtocol for CNMutableContact
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref