I had this error because I was doing this :

if(currentMeal?.State == .Deleted){

}

instead of

if(currentMeal!.State == .Deleted){

}

so I think optional not unwrapped in if condition can cause this error