나는 앱에서 일하고 있으며 오른쪽으로 스 와이프하고 삭제를 클릭하여 행을 삭제하는 삭제 옵션을 만들고 싶습니다. "Expected Declaration"오류가 발생하고 약 20 분 동안 수정하려고했습니다.예상 선언 오류 예상 됨 TableView
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var StoredValues = Values()
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return UITableViewCell()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: "meunSegue", sender: self)
func prepare(for segue: UIStoryboardSegue, sender: Any?) {
_ = segue.destination as! SecondViewController
}
class SecondViewController: UIViewController {
var recievedData = ""
override func viewDidLoad() {
super.viewDidLoad()
print(recievedData)
}
}
}
- (void)tableView:(UITableView *)tableView committEditStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath: (NSIndexPath *)indexPath {if (editingStyle == UITableViewCellEditingStyleDelete) {
[maTheData removeObjectAtIndex: [indexPath row]];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
코드가 엉망입니다. Swift와 혼합 된 ObjC 함수 (닫기 대괄호 누락) 및 다른 함수 내부의 함수 AND 클래스가 있습니다. 또한 오류가 발생한 행을 알려주지 않으므로 컴파일러가 아닙니다. – EmilioPelaez
미안 에러가 다음 행되어 약 –
- (공극)를 tableView (jQuery과 *)를 tableView committEditStyle (UITableViewCellEditingStyle) editingStyle forRowAtIndexPath (NSIndexPath *) indexPath {경우 (editingStyle == UITableViewCellEditingStyleDelete) { [maTheData removeObjectAtIndex : [indexPath 행]]; –