简体   繁体   English

xcode期望选择器用于objective-c方法和缺少@end错误

[英]xcode Expected Selector for objective-c method and Missing @end errors

Here is my code 这是我的代码

#import "MasterViewController.h"
#import "DiseaseResultsViewController.h"

@interface MasterViewController ()
@end

@implementation MasterViewController

@synthesize symptomTextField;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"searchFunctionSegue"])
    {
        if ([self.symptomTextField.text length])
        {
            DiseaseResultsViewController *resultsViewController = [segue destinationViewController];

            resultsViewController.symptomSearchString = self.symptomTextField.text;
        }
    }
}

@end

I am getting an "Expected selector for Objective-C method" error on the "if ([self.symptomTextField.text length]) line 我在“if([self.symptomTextField.text length]”行上得到“Objective-C方法的预期选择器”错误

and a "expected method body" and "missing @end" error in the line below the "DiseaseResultsViewController *resultsViewController = [segue destinationViewController]" line 并在“DiseaseResultsViewController * resultsViewController = [segue destinationViewController]”行下面的行中出现“expected method body”和“missing @end”错误

and I already checked all my imported files have their @end correctly. 我已经检查了所有导入的文件正确的@end。

Any ideas? 有任何想法吗?

In my case the error was reported in the .h: 在我的情况下,错误是在.h中报告的:

在此输入图像描述

But the problem was in the .m: 但问题出在.m:

在此输入图像描述

There was a typo, I enter a + by mistake. 有一个错字,我错误地输入+。

This was one of the most frustrating and silly errors I've seen. 这是我见过的最令人沮丧和愚蠢的错误之一。 I just cut and then pasted back in the code and the errors disappeared :S 我只是剪切然后粘贴在代码中,错误消失了:S

I had same error, I have written "+" sign in .m file` by mistake. 我有同样的错误,我错误地在.m文件中写了“+”符号。

After seeking code half an hour, I remove "+" sign and error was gone. 在寻找代码半小时后,我remove "+"符号,错误消失了。

I am sure you are too frustrated, just like I was. 我确信你太沮丧了,就像我一样。 In my case I had deleted the "@end" from the .h file and that was causing the error. 在我的情况下,我从.h文件中删除了“@end”,这导致了错误。 Add it again and the error disappears. 再次添加它,错误消失。 Take it easy. 别紧张。

More still in my case it was using the apparently reserved keyword 'connect' in a method declaration. 在我的情况下,更多的是在方法声明中使用明显保留的关键字'connect'。 Changing to '- (void)initConnect;' 更改为' - (void)initConnect;' solved it for me. 为我解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:#import上的“ Objective-C方法的预期选择器”和“预期方法主体” <Foundation/Foundation.h> - Errors: “Expected selector for Objective-C method” and “Expected method body” on #import <Foundation/Foundation.h> Xcode 7 swift,“未使用Objective-C选择器(函数)声明任何方法”警告 - Xcode 7 swift, ''no method declared with objective-c selector (function)" warning Objective-C:编译器错误将自身传递给选择器中的方法 - Objective-C: Compiler Errors Passing Self to Method in a Selector Xcode中不一致的Objective-C编译器错误 - Inconsistent objective-c compiler errors in Xcode 没有用Objective-C选择器声明的方法(&#39;nextPage&#39;) - No method declared with Objective-C selector ('nextPage') PageView Controller错误“目标C的预期选择器” - PageView Controller errors 'Expected selector for Objective C' 使用Objective-C选择器&#39;Method&#39;的方法&#39;Method()&#39;与具有相同Objective-C选择器的&#39;Method&#39;的getter冲突 - Method 'Method()' with Objective-C selector 'Method' conflicts with getter for 'Method' with the same Objective-C Selector Swift 2,使用Objective-C选择器'setOn:'的方法'setOn'与使用相同Objective-C选择器的'on'的setter冲突 - Swift 2, method 'setOn' with Objective-C selector 'setOn:' conflicts with setter for 'on' with the same Objective-C selector Swift-具有Objective-C选择器&#39;*&#39;的方法&#39;*()&#39;与具有相同Objective-C选择器的超类&#39;UIView&#39;中的&#39;*&#39;的getter发生冲突 - Swift - Method '*()' with Objective-C selector '*' conflicts with getter for '*' from superclass 'UIView' with the same Objective-C selector Swift - 使用Objective-C选择器&#39;*&#39;的方法&#39;*()&#39;与来自超类&#39;NSObject&#39;的&#39;*&#39;的getter冲突,具有相同的Objective-C选择器 - Swift - Method '*()' with Objective-C selector '*' conflicts with getter for '*' from superclass 'NSObject' with the same Objective-C selector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM