Swift 3.0用のコードを更新していて、アプリケーションが開いたときにiCloudと同期してフェッチ要求を実行します。Core Dataでオプションの値をアンラッピングしている間に予期せぬことにnilが見つかりました
私はappDelegate
func syncWithCompletion(_ completion:@escaping (_ completed:Bool) -> Void) {
if !ensemble.isLeeched {
ensemble.leechPersistentStore { error in
if error != nil {
print("cannot leech \(error!.localizedDescription)")
completion(false)
}
else {
print("leached!!")
completion(true)
}
}
}
else {
ensemble.merge{ error in
if error != nil {
print("cannot merge \(error!.localizedDescription)")
completion(false)
}
else {
print("merged!!")
completion(true)
//NSNotificationCenter.defaultCenter().postNotificationName("Updated-DB", object: nil)
}
}
}
}
に次の関数を実行し、次の
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.syncWithCompletion { (completed) -> Void in
}
のためのオプションのエラーを取得するしかし、私は、オプションのエラーは、Xcodeの更新機能何のためにあるのかわかりません移行時のヘッダー。
はUPDATE:だから私は、エラーことがわかったので、どうやら次
にnil値
を持っているしかし、私はスウィフト3移行
xCodeにすべての威力のブレークポイントを置き、エラーがどこにあるのかを教えてください。 –
@PavelGatilov質問を更新しました。 –
の移行時に何が変わったのかをもう一度確認しようとしていますが、どこがクラッシュするのでしょうか? –