我正在嘗試使用基於哪個表格單元格被選中的信息填充詳細視圖控制器。我試圖做什麼,我認爲可能的工作,但我得到的錯誤「使用未解決的標識符‘細節’的上說行,如果(詳細)在詳細視圖控制器類。在swift中使用交叉類變量
@IBOutlet var detailText: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
if (detail = "conferenceapp") {
self.detailText.text = "lol"
}
if (detail = "spaceshooter") {
self.detailText.text = "spaceshooter"
}
展位結構
struct Booth {
let category : String
let name : String
let detail : String
}
表視圖控制器類代碼段
var booths = [Booth]()
var filteredBooths = [Booth]()
override func viewDidLoad() {
super.viewDidLoad()
//fill array with data
self.booths = [Booth(category: "Tech", name: "Conference App", detail: "conferenceapp"),
Booth(category: "Tech", name: "Space Shooter", detail: "spaceshooter"),
Booth(category: "Tech", name: "RollABall", detail: "rollaball"),
Booth(category: "Animation", name: "Sugar Hill City Model", detail: "sugar"),
Booth(category: "Animation", name: "3D Sculpting 101", detail: "3d"),
Booth(category: "Animation", name: "HowTo - Texture", detail: "howto"),
Booth(category: "Science", name: "AP Biology for Dummies", detail: "apbio"),
Booth(category: "Science", name: "Cells", detail: "cells"),
Booth(category: "Science", name: "Space", detail: "space")]
PL緩解幫助,我需要修復錯誤
我想在展臺結構中設置等於如self.booths = [展位(類別:「技術」,名稱:「會議應用程序」,細節:「conferenceapp」)的字符串中的細節, – user3558131 2014-10-30 01:47:23
在細節類中,我必須檢查「細節」是否等於它在這些「展位(類別:」技術「,名稱:」太空射手「,細節:」太空射手「)中設置的任何字符串, 展位(類別:「Tech」,名稱:「RollABall」,詳細信息:「rollaball」), 展位(類別:「動畫」,名稱:「Sugar Hill City Model」,細節:「糖」), 展位「動畫」,名稱:「3D雕刻101」,詳細信息:「3d」),' – user3558131 2014-10-30 01:49:44
您仍按照我向您展示的方式進行。我假設表的每一行都從數組中獲取一個元素?如果是這樣你在我的示例 – 2014-10-30 01:52:21