Skip to content

Commit 94b4f5b

Browse files
committed
prevent crash if result is empty
1 parent 21902b5 commit 94b4f5b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

bk2ch16p678mediaQuery/ch29p946mediaQuery/ViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class ViewController: UIViewController {
135135
print(album.representativeItem!.albumTitle!)
136136
}
137137
// and here are the songs in the first of those albums
138+
guard result.count > 0 else {print("No sonatas"); return}
138139
let album = result[0]
139140
for song in album.items { //
140141
print(song.title!)

0 commit comments

Comments
 (0)