I'm working on a Swift project and I keep getting this error: "Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value" on this block of code:
func addPicture(pic: Picture!){
pictureArray.append(pic)
}
(Note: I've tried it both as pic: Picture
and pic: Picture!
and I get the same error either way)
pictureArray is defined as such:
var pictureArray: [Picture]!
I get this error when I'm trying to save the picture and pop the current VC:
@objc func dismissViewControllerAndSave() {
let picture = Picture(name: "NewPic", preview: "newpic", colorDictionary: [:], blueprint: [])
let viewController = ViewController()
viewController.addPicture(pic: picture)
self.navigationController?.popViewController(animated: true)
}
I've been working on trying to fix this issue for a long time and I'm not sure how to resolve it. picture
isn't an optional value so I have no clue why I keep getting this error. I'd really appreciate any type of help I could get. Thanks!