0
我剛開始學習ObjectiveC,iOS和Xcode。 我遵循standford uni教程。我有以下課程,我已經在PsychologistViewController's
實現中定義了一種名爲setAndShowDiagnosis:(int)diagnosis
的方法。當我把這種方法時,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]的屬性;''VS [自setAndShowDiagnosis:20];'。這個錯誤會討論一個'property',因爲它需要一個,而你混合了方法和屬性。 – Larme 2014-09-25 09:22:43
真的出蘋果命名約定的它setAndShowDiagnosis的'名字:'真的應該' - (空)performSequeWithDiagnosis:(INT)診斷;'存在的原因是因爲你對所傳遞的診斷價值進行動作塞克。對於代碼評論中的命名約定,我只是一個痛苦而已。 – Popeye 2014-09-25 09:30:28