Bu benim kodum.İstenmeyen mesaj oluşturulamıyor
import UIKit
class FirstViewController: UIViewController, UITextFieldDelegate, UINavigationControllerDelegate {
//MARK: PROPERTIES
@IBOutlet weak var jotTextField: UITextField!
@IBOutlet weak var saveButton: UIBarButtonItem!
/*
This value is either passed by `MealTableViewController` in `prepareForSegue(_:sender:)`
or constructed as part of adding a new meal.
*/
var jot: String?
//MARK: UITextFieldDelegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Hide the keyboard.
textField.resignFirstResponder()
return true
}
func textFieldDidEndEditing(textField: UITextField) {
jotTextField.text = textField.text
}
//MARK: Navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if saveButton === sender {
var jot = jotTextField.text ?? ""
jot = String(jotTextField)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Handle the text field’s user input through delegate callbacks.
jotTextField.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func unwindToJotList(sender: UIStoryboardSegue) {
if let sourceViewController = sender.sourceViewController as? FirstViewController, jot = sourceViewController.jot {
let newIndexPath = NSIndexPath(forRow: jot.count, inSection: 0)
jot.append(jot)
JotTableViewCell.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Bottom)
}
}
}
Ben bir çözülme segue oluşturmaya çalışıyorum ancak ben bu hatlarda hataları alıyorum:
let newIndexPath = NSIndexPath(forRow: jot.count, inSection: 0)
jot.append(jot)
JotTableViewCell.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Bottom)
İlk hattın hatası:
'count' is unavailable
İkinci hattın hatası:
Cannot use mutating member on immutable value: 'jot' is a let constant
nt. Bunu bir değişken olarak ilan ettim ('var').
Üçüncü hattın hatası:
Type 'jotTableViewCell' has no member 'insertRowsAtIndexPaths'
bana yardım edin. Swift programlama diline çok yeniyim, bir noob/acemi olduğumu söyleyebilirsin. Bu muhtemelen deneyimli bir programcı için çok basit bir düzeltme gibi görünüyor, o kadar da değil. Zaman ayırdığın için teşekkürler.
Belki de yeterince açık değildi - Bir düğme dokunulduğunda, bunun ardından bir tabloya sadece daktilo edilmişti ne katacak orijinal ekrana geri gider ve böylece bu açma segue olduğunu görünüm. – user3003189