다음 코드는 무엇이 문제입니까? Xcode 4는 아래 코드의 주석에 표시된대로 "Question"메시지 앞에 "Question"이있는 두 메서드 선언이 "Question"메시지 전에 컴파일되지 않는다고 말합니다. Question 클래스가 컴파일되고이 코드는 . 이전에 일하고있다 나는 질문을 일부 변경했다하지만,이 컴파일 시간 오류를 파악하는 시도를 철회 여기 컴파일러 오류 - iOS "expected") "before"질문
#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