Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 预期声明错误TableView_Ios_Swift_Uitableview_Tableview_Tablecell - Fatal编程技术网

Ios 预期声明错误TableView

Ios 预期声明错误TableView,ios,swift,uitableview,tableview,tablecell,Ios,Swift,Uitableview,Tableview,Tablecell,我正在开发一个应用程序,希望创建一个删除选项,在该选项中,您右击并单击“删除”删除一行。我遇到了一个“预期声明”错误,我已经尝试了大约20分钟来修复它 import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var StoredValues = Values() override func viewDidLoad() {

我正在开发一个应用程序,希望创建一个删除选项,在该选项中,您右击并单击“删除”删除一行。我遇到了一个“预期声明”错误,我已经尝试了大约20分钟来修复它

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];


    }
}

方法中有一个方法,而不是调用该方法。换句话说,
func
中的
func
。更进一步,我不知道你怎么可能把
放在
函数
中?正如Sandeep所提到的,您还将
目标C
Swift
混为一谈

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];

这看起来像是目标C,而你们班的其他同学都在Swift。当您使用多种语言时,很容易混淆,但编译器在这种情况下为您提供了很好的帮助。

您的代码乱七八糟。您有一个ObjC函数(缺少右括号),它混合了Swift和另一个函数中的一个函数和一个类。您还忘了告诉我们错误出现在哪一行,我们不是编译器。很抱歉,错误出现在这些行中—(void)tableView:(UITableView*)tableView CommittedStyle:(UITableViewCellEditingStyle)editingStyle for RowatineXpath:(NSIndexPath*)indexPath{if(editingStyle==UITableViewCellEditingStyle){[maTheData removeObjectAtIndex:[indexPath行]];