类中定义的方法无法识别

时间:2014-09-25 09:19:28

标签: ios objective-c

我刚刚开始学习ObjectiveC,iOS和Xcode。 我正在关注Standford uni教程。我有以下类,我在setAndShowDiagnosis:(int)diagnosis实现中定义了一个名为PsychologistViewController's的方法。当我调用这个方法时,Xcode会说以下内容:

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

任何想法为什么? 对不起基本问题,但我是MVC等的新手

//
//  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

1 个答案:

答案 0 :(得分:1)

[self setAndShowDiagnosis:20];

你可以这样调用这个函数。您的代码正在尝试访问自己的属性

[self.setAndShowDiagnosis:20];