I have an UIAlertController that allows a user to add a name and description of their smart advice. I would now like for the UIAlertController to allow the user to upload an image from their camera roll. I don't have any database or coredata enabled (Do I need to?). Here is my UIAlertController:
@IBAction func refreash(_ sender: AnyObject) {
let alert = UIAlertController(title: "Add Smart Device", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alert.addTextField(configurationHandler: { textField in
textField.placeholder = "Enter Name of the Smart Device Here"
})
alert.addTextField(configurationHandler: { textField in
textField.placeholder = "Enter Desc of the Smart Device Here"
})
// I want something like alert.addImagePicker here
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
if let name = alert.textFields?.first?.text,
let desc = alert.textFields?[1].text {
self.mySmartDeviceList.addSmartDevice(name: name, desc: desc, image: "robot.jpg")
let indexPath = IndexPath (row: self.mySmartDeviceList.getCount() - 1, section: 0)
self.cityTable.beginUpdates()
self.cityTable.insertRows(at: [indexPath], with: .automatic)
self.cityTable.endUpdates()
}
}))
self.present(alert, animated: true)
}
See how it says that the image is just "robot.jpg"? I want that to be the image that the user uploaded.