turtleboy
turtleboy

Reputation: 7574

method defined in class not recognised

I'm just starting out learning ObjectiveC, iOS and Xcode. I'm following the standford uni tutorials. I have the following class where i have defined a method called setAndShowDiagnosis:(int)diagnosis inside the PsychologistViewController's implementation. When i call this method, Xcode is saying the following:

/Users/matthewwomersley/Documents/developer/Psychologist/Psychologist/PsychologistViewController.m:50:11: Property 'setAndShowDiagnosis' not found on object of type 'PsychologistViewController *'

Any ideas why? Sorry for a basic question but i'm new to MVC etc

//
//  PsychologistViewController.m
//  Psychologist
//
//  Created by matthew womersley on 25/09/2014.
//  Copyright (c) 2014 com.carefreegroup. All rights reserved.
//

#import "PsychologistViewController.h"
#import "HappinessViewController.h"

@interface PsychologistViewController ()
@property (nonatomic) int diagnosis;
@end






@implementation PsychologistViewController

@synthesize diagnosis = _diagnosis;



- (void)setAndShowDiagnosis:(int)diagnosis{

    self.diagnosis = diagnosis;
    [self performSegueWithIdentifier:@"ShowDiagnosis" sender:self];

}



-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{


    if([segue.identifier isEqualToString:@"ShowDiagnosis"]){

        [segue.destinationViewController setHappiness:self.diagnosis];
    }

}



- (IBAction)flying {

    [self.setAndShowDiagnosis:85];
}



- (IBAction)apple {

    [self.setAndShowDiagnosis:100];

}


- (IBAction)dragons {

    [self.setAndShowDiagnosis:20];

}


@end

Upvotes: 0

Views: 49

Answers (1)

Raymond Brion
Raymond Brion

Reputation: 332

[self setAndShowDiagnosis:20];

You call the function like this. Your code is trying to access a property of self

[self.setAndShowDiagnosis:20];

Upvotes: 1

Related Questions