2

We get .vcf from Document directory path but can't import to the device using .vcf file URL like

'"Nik1 .vcf": file:///Users/jksol-niketan/Library/Developer/CoreSimulator/Devices/18ADE140-22E4-4BEA-8C25-886AEE96C2CC/data/Containers/Data/Application/BC6A91A7-2920-4D5D-9787-F6D0E0DAB200/Documents/restore/Nik1%20.vcf'

How can solution for this file path URL to import iPhone device using swift/objective c I tired of this issue, help with this query solution.

for r in restore{
                  var data: Data = Data()
                            do{
                                let url = URL(fileURLWithPath: r.value.path)
                                try data = NSData(contentsOf: url) as Data
                                var usersContact = [CNContact]()
                                    do {
                                        try usersContact = CNContactVCardSerialization.contacts(with: data)
                                    } catch {
                                        print("error")
                                    }
                                let contact = usersContact[0]
                                print(contact)
                            }catch{
                                print("error")
                            }
                        }

Ex. restore = ["Nik1 .vcf": file:///Users/jksol-niketan/Library/Developer/CoreSimulator/Devices/18ADE140-22E4-4BEA-8C25-886AEE96C2CC/data/Containers/Data/Application/BC6A91A7-2920-4D5D-9787-F6D0E0DAB200/Documents/restore/Nik1%20.vcf]

iraj jelodari
  • 3,118
  • 3
  • 35
  • 45
  • 2
    `print("error")` => `print("error: \(error)")` instead. Is there an error printed anyway? What is your issue exactly? What's wrong? Where is your code going? falling into a catch? Which one? – Larme Feb 21 '20 at 10:35

0 Answers0