0
レルムで2つのテキストファイルを保存して削除するにはどうすればよいですか?レルムで2つのテキストファイルを保存して削除するにはどうすればよいですか?
class ViewController: UIViewController , UITableViewDataSource , UITableViewDelegate {
@IBOutlet weak var text1: UITextField!
@IBOutlet weak var text2: UITextField!
@IBOutlet weak var ttableview: UITableView!
//delete row and tableview and array
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
array1.remove(at: indexPath.row)
array2.remove(at: indexPath.row)
ttableview.deleteRows(at: [indexPath], with: .fade)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array1.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = ttableview.dequeueReusableCell(withIdentifier: "cell") as! Cell
cell.lable1.text = array1[indexPath.row]
cell.lable2.text = array2[indexPath.row]
return cell
}
var array1 = [String]()
var array2 = [String]()
}
私は保存し、テーブルビューに私の2つのテキストフィールドを削除する:続き
は私のコードです。以下は
あなたが最初のレルムのマニュアルを読む必要があり
@IBAction func Add(_ sender: Any) {
array1.insert(text1.text!, at: 0)
array2.insert(text2.text!, at: 0)
self.ttableview.reloadData()
}
func queryPeople(){
let realm = try! Realm()
let allPeople = realm.objects(CCat.self)
for person in allPeople {
print("\(person.name) to \(person.job)")
}
}
このコードで直面している問題は何か言及してください、また、いくつかの説明を追加してください。 –
ここで領域を使用する方法私は削除のデータを保存したい私はあなたが私を助けることができるコードをしたいですか? –