PsychologistViewController

PsychologistViewController

我刚开始学习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

最佳答案

[self setAndShowDiagnosis:20];


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

[self.setAndShowDiagnosis:20];

08-25 21:41