On my app the user has a profile picture, if signed in with Facebook the profile picture is set to there current Facebook profile picture. The issue i have is if the user signs into the app without Facebook the app crashes when trying to retrieve the Facebook data. How can i make it safe so if the Facebook data cannot be got then the profile picture can be set to blank.
lazy var profileImageView: UIImageView = {
let user = FIRAuth.auth()?.currentUser
let photoUrl = user?.photoURL
let data = NSData(contentsOfURL: photoUrl!)
let profileView = UIImageView()
profileView.image = UIImage(data: data!)
profileView.contentMode = .ScaleAspectFill
profileView.layer.cornerRadius = 16
profileView.layer.masksToBounds = true
profileView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleSelectProfileImageView)))
profileView.userInteractionEnabled = true
return profileView
}()