私は現在、迅速にテーブルビューベースのプロジェクトに取り組んでいます。私は2つのテーブルビューが私のプロジェクトで実行している。私の最初の(お気に入りとして)セルを削除するeditActionsForRowAtIndexPath機能を持つデータをロードのtableView、次のコードを使用しています、私の第二tableview.Iに移動.....としてすぐにテーブルビューデータを保存する
firstTableView:
var arrays = ["Alpha","Beta","Gamma","Phill","Below","Above","Clean",]
var deleted: [String] = []
//passing data to another tableVC
var sendSelectedData = NSString()
let defaults = NSUserDefaults.standardUserDefaults()
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let favorite = UITableViewRowAction(style: .Normal, title: "Favourite") { action, index in
print("favourite button tapped")
let editingStyle = UITableViewCellEditingStyle.Delete
if editingStyle == UITableViewCellEditingStyle.Delete {
self.tableView.beginUpdates()
self.deleted.append(self.arrays[indexPath.row])
self.arrays.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
self.tableView.endUpdates()
}
}
favorite.backgroundColor = UIColor.orangeColor()
return [favorite]
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "ShowDetails") {
// initialize new view controller and cast it as your view controller
let viewController = segue.destinationViewController as! favTableViewController
// your new view controller should have property that will store passed value
viewController.arrayx = deleted
}
}
上記のコードは、私が計画した通りに動作します。スワイプアクションが実行されるたびに、その特定のセルが私の第2のビューcontroller.Butに移動されて、私はトラブルセーブデータを取得し、tableViewCell
後の両方の私の第一および第二のtableView
コントローラ上tableview
をリロードしていますが、私の私が知っている二tableView
...
NSUserDefaults
機能に移動されますdata.Butに保存し、私はNSUserdefaults
。だからを使用して慣れていない午前、誰かが私に方向を指してください...事前に
おかげで...
Realm.io(https://realm.io/docs/swift/latest/:あなたのプロジェクトに以下のビデオをレルムを統合する方法を学習したい場合は、絶対的な基礎から始めます)は、最も簡単な学習曲線IMOを持っています。彼らのドキュメントは非常に包括的で、簡単にナビゲートできます。 –