IOS Contacts--Write information

Source: Internet
Author: User

Wrote the basics and the ability to query the Address Book now let's take a look at writing information

    • New
    • Modify
    • Delete
#pragma mark-Write contact information//Create contact-(void) creatnewrecord{cferrorref error = NULL;        Create an Address Book Action object Abaddressbookref addressbook = Abaddressbookcreatewithoptions (NULL, &error);        Create a new contact record abrecordref NewRecord = Abpersoncreate ();        Add attribute values for new contact records Abrecordsetvalue (NewRecord, Kabpersonfirstnameproperty, (__bridge cftyperef) @ "Cedar", &error);    Create a multivalued attribute abmutablemultivalueref multi = abmultivaluecreatemutable (Kabmultistringpropertytype);    Abmultivalueaddvalueandlabel (Multi, (__bridge cftyperef) @ "12345678990", Kabpersonphonemobilelabel, NULL);        Abmultivalueaddvalueandlabel (Multi, (__bridge cftyperef) @ "11234567890", Kabpersonphoneiphonelabel, NULL);    Add multivalued attribute to record Abrecordsetvalue (NewRecord, Kabpersonphoneproperty, Multi, &error);        Cfrelease (multi);        Add record to Address Book operand Abaddressbookaddrecord (AddressBook, NewRecord, &error);    Save Address Book Action object Abaddressbooksave (AddressBook, &error);    Cfrelease (NewRecord); CfrelEase (addressbook);}    -(void) editrecord{cferrorref error = NULL;    Abaddressbookref addressbook = abaddressbookcreatewithoptions (NULL, &error);    Abrecordid RecordID = [Personidasnumber intvalue];        Abrecordref record = Abaddressbookgetpersonwithrecordid (AddressBook, RecordID);    Set phone number Abmutablemultivalueref multi = abmultivaluecreatemutable (Kabmultistringpropertytype);    Abmultivalueaddvalueandlabel (Multi, (__bridge cftyperef) @ "12345678900", Kabpersonphonemobilelabel, NULL);        Abmultivalueaddvalueandlabel (Multi, (__bridge cftyperef) @ "12345678900", Kabpersonphoneiphonelabel, NULL);    Add phone number to database Abrecordsetvalue (record, Kabpersonphoneproperty, multi, &error);        Cfrelease (multi);    Save to Database Abaddressbooksave (AddressBook, &error);    Cfrelease (AddressBook);    }-(void) deleterecord{cferrorref error = NULL;    Abaddressbookref addressbook = abaddressbookcreatewithoptions (NULL, &error); Abrecordid RecordID = [Personidasnumber IntvAlue];        Abrecordref record = Abaddressbookgetpersonwithrecordid (AddressBook, RecordID);        Delete Records Abaddressbookremoverecord (AddressBook, Record, &error);    Save to Database Abaddressbooksave (AddressBook, &error); Cfrelease (addressbook);}


IOS Contacts--Write information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.