浏览代码

Safeguards while feching festival data.

Iñigo Valentin 9 年之前
父节点
当前提交
bd110f443e
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      app/LablancaView.swift

+ 6 - 3
app/LablancaView.swift

@@ -101,10 +101,13 @@ class LablancaView: UIView {
 			
 			// Get info from festivals
 			let searchResults = try context.fetch(fetchRequest)
-			let r = searchResults[0]
 			
-			// Set description
-			self.fText.text = r.value(forKey: "text_\(lang)") as! String?
+			if searchResults.count > 0 {
+				let r = searchResults[0]
+			
+				// Set description
+				self.fText.text = r.value(forKey: "text_\(lang)") as! String?
+			}
 
 		} catch {
 			NSLog(":LABLANCA:ERROR: Error getting festivals info: \(error)")