Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

and a "expected method body" and "missing @end" error in the line below the "DiseaseResultsViewController *resultsViewController = [segue destinationViewController]" line

and I already checked all my imported files have their @end correctly.

Any ideas?

like image 358
Yannis P. Avatar asked Oct 05 '13 16:10

Yannis P.


3 Answers

In my case the error was reported in the .h:

enter image description here

But the problem was in the .m:

enter image description here

There was a typo, I enter a + by mistake.

like image 108
Javier Calatrava Llavería Avatar answered Nov 08 '22 05:11

Javier Calatrava Llavería


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

like image 44
Yannis P. Avatar answered Nov 08 '22 03:11

Yannis P.


I had same error, I have written "+" sign in .m file` by mistake.

After seeking code half an hour, I remove "+" sign and error was gone.

like image 2
Faisal Tanveer Avatar answered Nov 08 '22 04:11

Faisal Tanveer