有什麼不對下面的代碼? Xcode 4是說,帶有「Question」的兩個方法聲明由於「Question」之前的「expected」)而不能編譯,如下面代碼中的註釋所示:Question類編譯並且此代碼。以前已經工作,我做了一些修改的問題,而是支持他們去揣摩這個編譯時錯誤編譯器錯誤 - iOS設備的「預期‘)問題’之前」
#import <Foundation/Foundation.h>
#import "Question.h"
@interface AppState : NSObject {
int chosenAnswer;
int correctAnswers;
int currentQuestionNumber;
// this will contain the hash table of question objects
NSMutableDictionary *questionHash;
}
@property (nonatomic) int chosenAnswer;
@property (nonatomic) int correctAnswers;
@property (nonatomic) int currentQuestionNumber;
@property (nonatomic, retain) NSDictionary *questionHash;
- (void) printQuestions;
- (void) printDescription;
- (void) addQuestion: (Question *) question; // <==== error
- (int) numberOfQuestions;
- (void) saveState;
- (void) resetState;
- (Question *) currentQuestion; // <===== error
@end
這裏的Question.h:?
#import <Foundation/Foundation.h>
#import "AppState.h"
@interface Question : NSObject {
NSString *questionTxt;
int correctAnswer;
int number;
// this will contain the hash table of questions_answer objects
NSMutableDictionary *answerHash;
}
@property (nonatomic, retain) NSString * questionTxt;
@property (nonatomic) int correctAnswer;
@property (nonatomic) int number;
@property (nonatomic, retain) NSMutableDictionary *answerHash;
-(void) addAnswer: (NSString *) answer;
- (NSMutableArray *) answerArray;
- (void) printDescription;
- (void) printAnswers;
- (NSString *) correctAnswerText;
- (Question *) currentQuestion;
@end
你可以張貼Question.h? – Maz
是的,我懷疑問題其實不是一種類型,或者是奇怪的東西。 – jtbandes