I am creating an app using swift in xcode 10 that would allow user to create digital portfolios viewed in UIview, this UI view will contain their names , portfolio links and other stuff related to their profession. I have not done anything on it yet, I just want to know how can I extract data from the view to convert to vcard so I can share it
Asked
Active
Viewed 93 times
1 Answers
0
So if get it correctly you will have an application that lets a user fill in his information and create a digital portfolio, after that you want to the user to able to share the information outside of the app. I am not exactly sure what you mean by "extract" but on iOS using swift you can share information like this.
Inside your viewController:
override func viewDidLoad() {
super.viewDidLoad()
let items: [Any] = ["Put whatever you want to share in here", URL(string: "https://www.apple.com")!]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
self.present(ac, animated: true)
}
This will bring up the activity controller.

Nick
- 242
- 2
- 12
-
so imagine you are have filled up the sign up form, these details will then be displayed to a UIview. all the necessary information such as names, links ,number, these are the information that I need to put Ito a vcard. I want to extract just those and put it into a shareable vcard. I hope I explained it properly – Jove Apr 17 '20 at 12:35
-
You will have to use the activityViewController to share the information you need anyways. In order to share them in a "vCard" you will have to make some kind of an image file (pdf, png etc) and then let the user share it. I think the term extract is not the best one, you already have access to the viewController you just take variables that these info are stored (names, links, number, etc) and use them to generate the vCard, then you share the vCard using the code above. – Nick Apr 17 '20 at 12:46
-
this is perfect thank you, do you know how to generate a pdf out of the variables? – Jove Apr 19 '20 at 00:07
-
Never had to make a pdf before, you should check this tutorial: https://www.raywenderlich.com/4023941-creating-a-pdf-in-swift-with-pdfkit – Nick Apr 19 '20 at 13:09