[英]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.