ContactHelperSwift3 contains Fetch, Delete, Add and Update Contact Functionality
Contact List And Search Contact
Delete Contact
Add Contact
Update Contact
CountrySelect
with the help of this, We can Fetch Contact, Delete Contact from Device and Add/Update Contact To Device. We Can also modify According to our requirement.
Advantages of this Demo: 1: Contact Functionality
Fetch , Delete , Update, Add Contact
2: Country Picker Functionality
Search Functionality, Country picker Added, Country JSON Self Made. Convert Country Code To Country Name.
Steps:
-
import Contacts and ContactsUI frameworks in your project.
-
In info.plist File add key : Privacy - Contacts Usage Description.
-
Add this line In viewWillAppear function
ContactHelper.objContactHelper.delegateContact = self
- Fetch Contact Details
ContactHelper.objContactHelper.getContactList(controller: self)
// Here Self is ViewController
// When We Call Above Method then Below Delegate Method is Automatic Call Through Delegate
func allContactList(array: NSArray)
this method is Delegate Method that Contains Array of Contact Details
- Add NewContact Details
ContactHelper.objContactHelper.addContact(addDic: dicDetails, controller : self)
// Here DicDetails
let DicDetails: NSDictionary = ["Fullname": ArrayOFFullname , "Mobile": fullNo, "EmailID" : emailId]
// self is ViewController
- Update Contact Details
ContactHelper.objContactHelper.updateContact(addDic: dicDetails, contactModel: contactModel!, controller: self)
// Here DicDetails
let DicDetails: NSDictionary = ["Fullname": ArrayOFFullname , "Mobile": fullNo, "EmailID" : emailId]
// ContactModel is contactModel which you want to Update
// self is ViewController
// After Add/Update Method
Below Delegate Method is Called
func contactAddedOrUpdateSuccess()
- Delete Contact Detail
ContactHelper.objContactHelper.deleteContact(dicdata: dicData, controller: self)
// Here Dicdata is your ContactDetails
// in DicData ContactModel is Available which we want to Delete
Note: please print DicData then You will know
// self is ViewController
// After Delete successfull Fetch Contact Details With this Delegate Method
func allContactList(array: NSArray)
- Take Extension of ContactFetchDelegate
//These Are Delegate Methods of ContactFetchDelegate
func allContactList(array: NSArray) func contactAddedOrUpdateSuccess() func updateDetails(indexpathValue: IndexPath)
- You Can Also Modify ContactHelper.swift According yo your requirement
// Please Check Demo For More Details