#import "PsychologistViewController.h"
#import "HappinessViewController.h"
@interface PsychologistViewController()
@property (nonatomic) int diagnosis;
@end
@implementation PsychologistViewController
@synthesize diagnosis = _diagnosis;
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ShowDiagnosis"]) {
[segue.destinationViewController setHappiness:self.diagnosis];
}
else if ([segue.identifier isEqualToString:@"Celebrity"]) {
[segue.destinationViewController setHappiness:100];
}
else if ([segue.identifier isEqualToString:@"Serious"]) {
[segue.destinationViewController setHappiness:20];
}
else if ([segue.identifier isEqualToString:@"TV Kook"]) {
[segue.destinationViewController setHappiness:50];
}
}
****- (void)setAndShowDiagnosis:(int)diagnosis****
{
self.diagnosis = diagnosis;
[self performSegueWithIdentifier:@"ShowDiagnosis" sender:self];
}
-(IBAction)flying
{
[self setAndShowDiagnosis:85];
}
-(IBAction)apple
{
[self setAndShowDiagnosis:100];
}
-(IBAction)dragons
{
[self setAndShowDiagnosis:20];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end
我的问题与- (void)setAndShowDiagnosis:(int)diagnosis
方法有关。此方法在任何 .h 文件中的任何地方都未声明为公共的,显然它也不是私有的。我的问题是为什么会这样?它只显示了它的 setter 实现,但实际的方法声明却没有出现。任何有助于澄清这一点的帮助表示赞赏。哦,这是来自在线讲座,一切都编译得很好并且可以运行。