0
私はこのような状態でそれをチェックし(がかVARを聞かせて)、および関数の結果を取得し、別の変数で設定するたい:iOS Swift 3でガードアンドコンディションを使用する方法は?
guard galleryArr:Array<UIImage> = fetchGalleryImages() , galleryArr.count != 0 {
}else{
}
私にこの問題を解決する正しい方法を教えてください。
func doSomething() -> Int? {
guard let galleryArr = fetchGalleryImages(), galleryArr.count != 0 else {
// you must return from doSomething in here, be it by throwing
// a fatalError(), return nil, or some other value to indicate
// that the call has failed
return nil
}
// proceed with the function
return ...
}
fetchGalleryImages()はどのように定義されていますか?それは配列かオプションの配列を返しますか? –