試圖從我的UITableViewController到具有這些PFObjects的詳細視圖控制器...在此先感謝!準備segue ..從UITableView到DetailView與解析對象
錯誤我似乎無法調和...
「不能與類型‘字符串’的索引下標類型‘字符串’的值」我要被查詢的對象呈現細節視圖控制器上...
這裏是我的查詢和我的賽格瑞準備......我似乎無法訪問該對象的SEGUE準備...
var customerName = [String]()
var customerAddress = [String]()
var query = Pfuser.query
query.whereKey("userId",equalTo:adminFollowingUser)
query.findObjectsInBackgroundWithBlock({ (adminObjects, error) -> Void in
if let objects = adminObjects {
for object in objects {
self.customerName.append(object["customerName"] as! String)
self.customerAddress.append(object["customerStreetAddress"] as! String)
//下面是準備賽格......
override func prepareForSegue(segue: UIStoryboardSegue, sender:
AnyObject?)
{
if (segue.identifier == "thesePools")
{
let employeeDetailVC: EmployeeDetailViewController = segue.destinationViewController
as! EmployeeDetailViewController
// indexPath is set to the path that was tapped
let indexPath = self.tableView.indexPathForSelectedRow
let customerNameLabel = self.customerName[indexPath!.row]
let customerAddressLabel = self.customerAddress[indexPath!.row]
employeeDetailVC.customerString = customerNameLabel
employeeDetailVC.addressString = customerAddressLabel
這裏是我的詳細視圖控制器接收字符串。
//DetailViewController
var customerString = String()
var addressString = String()
override func viewDidLoad() {
super.viewDidLoad()
self.customerLabel.text = customerString
self.addressLabel.text = addressString
我得到了所有的錯誤,但當我點擊單元格它仍然不會繼續..我三重檢查了segue名稱,刪除和redid它三倍檢查目標視圖控制器的類名稱...不知道還有什麼做..我會說這是答案...但它仍然不工作:( –
你有沒有在故事板中的segue?你是怎麼做到的?另外,如果你使用「didSelectRowAtIndexPath」,確保它不是「 didDeSelectRowAtIndexPath「,這是一個經常犯的錯誤,你也必須在表視圖上」選擇單擊「,並將其繪製到視圖控制器,以用於數據源和委託,並且必須實現tableviewcontroller委託。 /中。com/@ ronm333/a-simple-table-view-example-in-swift-cbf9a405f975 – user1700737
這個文章太棒了!用那篇文章想出來了!非常感謝網址:) –