wie die Anzahl der Kontakte in Swift zu zählen, ich bin sehr neu zu diesem iOS-Plattform wollte ich nur wissen, wie man den Kontakt zugreifen und zählen. Alle gültigen Eingaben werden geschätzt.Wie zähle ich die Anzahl der Kontakte in swift?
//
// ViewController.swift
// test1
//
// Created by Lakshmi Kanth N on 6/23/17.
// Copyright © 2017 Lakshmi Kanth N. All rights reserved.
//
import UIKit
import Contacts
import ContactsUI
import AddressBook
class ViewController: UIViewController, CNContactPickerDelegate{
@IBOutlet var label: UILabel!
@IBOutlet var click: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let keysToFetch = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)]
// The container means
// that the source the contacts from, such as Exchange and iCloud
var allContainers: [CNContainer] = []
do {
allContainers = try contactStore.containersMatchingPredicate(nil)
} catch {
print("Error fetching containers")
}
print (allContainers.count)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func obclick(_ sender: UIButton) {
let entieyType = CNEntityType.contacts
let authStatus = CNContactStore.authorizationStatus(for: entieyType)
if authStatus == CNAuthorizationStatus.notDetermined{
let contactStore = CNContactStore.init()
contactStore.requestAccess(for: entieyType, completionHandler: { (success, nil) in
if success {
self.openContacts()
}
else {
print("NOT")
}
})
}
else if authStatus == CNAuthorizationStatus.authorized{
self.openContacts()
}
}
func openContacts(){
let contactPicker = CNContactPickerViewController.init()
contactPicker.delegate = self
self.present(contactPicker, animated: true, completion: nil)
}
func contactPickerDidCancel(_ picker: CNContactPickerViewController) {
picker.dismiss(animated: true) {
}
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
}
}
oben ist mein Code, der die Kontakte zuzugreifen verwendet wird, aber ich brauche eine Anzahl von ihnen
nicht aufgelösten Bezeichner 'speichern' –
ich habe meinen Code PLZ Check einmal hochgeladen –