2017-03-15 21 views
-3

辞書の配列でtableViewを作成しました。どうすれば、セルの内容をコアデータに保存し、別のテーブルで取得できますか?テーブルビューから別のTableVIewへの3速データのスウィフト?

私はのtableViewへの辞書の配列をロード:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SourceTableViewCell 
    cell.titleLabel.text = sourceFeeds[indexPath.row]["title"] 
    cell.linkLabel.text = sourceFeeds[indexPath.row]["link"] 


    return cell 

} 

今、私はコアデータにそれらのリンクとタイトルを保存したいセルを選択して

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 

    self.tableView.deselectRow(at: indexPath, animated: true) 

    let cell = self.tableView.cellForRow(at: indexPath) as! SourceTableViewCell 


    if self.tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCellAccessoryType.none { 

     self.tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.checkmark 



    } else { 


     self.tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.none 



    } 


} 

を私はsourceFeeds」というを言及したいと思います"配列はplistからロードされました!

+1

これは非常に広いです。あなたはこれまでに試したことを示すことができますか? – brimstone

+0

'tableView.cellForRow(at')を3回呼び出すのは非常に非常に非効率です。 – vadian

答えて

0

私は最終的に私の問題の解決策を見つけました!

関連する問題