The App works fine on the simulator.
When I run it on my iPhone, the image is picked out fine and it even displays the image.
But the Label which should say 'Unknown' initially is not visible. When I use Rename from the UIAlertController, I present another alert controller with a text field for name.
As soon as I type the first letter in the text field, an error shows up in my Xcode console:
2020-07-21 13:19:24.679451+0530 Project10[33091:14325443] [general] Connection to daemon was invalidated
Here is my didSelectItemAt:
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let person = people[indexPath.item]
let ac = UIAlertController(title: nil, message: nil, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "Rename", style: .default){
[weak self] _ in
let ac1 = UIAlertController(title: "Rename Person", message: nil, preferredStyle: .alert)
ac1.addTextField()
ac1.addAction(UIAlertAction(title: "Save", style: .default){
[weak self,weak ac1] _ in
guard let newName = ac1?.textFields?[0].text else {return}
person.name = newName
self?.collectionView.reloadData()
})
ac1.addAction(UIAlertAction(title: "Cancel", style: .cancel))
self?.present(ac1,animated: true)
})
ac.addAction(UIAlertAction(title: "Delete Person", style: .destructive){
[weak self] _ in
self?.people.remove(at: indexPath.item)
self?.collectionView.reloadData()
})
ac.addAction(UIAlertAction(title: "Cancel", style: .cancel))
present(ac,animated: true)
}