有什么不对下面的代码? 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