我有3个VC。A 显示问题和答案。当问题被错误选择时会显示 B,一旦级别清晰,就会显示 C。我从 AB 和 AC 出发时遇到问题。这是我的代码
#import "AViewController.h"
#import "BViewController.h"
#import "CViewController.h"
@interface AViewController ()
@end
现在这里是实现代码
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
BViewController *incorrect = [segue destinationViewController];
incorrect.currentQuestion = self.currentQuestion;}
//这里A正在向B发送关于哪个问题被错误回答的信息,即当前问题
- (void)viewDidLoad
{
[super viewDidLoad];
rootArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Addition1" ofType:@"plist"]];
currentQuestion = -1;
[self showNextQuestion];
}
-(void) showNextQuestion{
currentQuestion++;
if (currentQuestion <= 3) {
int numItems = [rootArray count];
NSMutableArray *question = [NSMutableArray arrayWithCapacity:numItems];
NSMutableArray *A = [NSMutableArray arrayWithCapacity:numItems];
NSMutableArray *B = [NSMutableArray arrayWithCapacity:numItems];
NSMutableArray *C = [NSMutableArray arrayWithCapacity:numItems];
NSMutableArray *addimage = [NSMutableArray arrayWithCapacity:numItems];
NSMutableArray *Answer = [NSMutableArray arrayWithCapacity:numItems];
for (NSDictionary *itemData in rootArray) {
[question addObject:[itemData objectForKey:@"question"]];
[A addObject:[itemData objectForKey:@"A"]];
[B addObject:[itemData objectForKey:@"B"]];
[C addObject:[itemData objectForKey:@"C"]];
[addimage addObject:[itemData objectForKey:@"ImageUse"]];
[Answer addObject:[itemData objectForKey:@"ANS"]];
}
self.questionasked.text = question[currentQuestion];
self.answer1.text = A[currentQuestion];
self.answer2.text = B[currentQuestion];
self.answer3.text = C[currentQuestion];
additionImage.image = [UIImage imageNamed:addimage[currentQuestion]];
self.correctAns = Answer[currentQuestion];}
else{
NSLog(@"End of Array ");
[self performSegueWithIdentifier:@"levelpassed" sender:nil];
}
}
这里上面的这个区域是我遇到问题的地方
当级别被清除时 C VC 显示此错误
[CViewController setCurrentQuestion:]: unrecognized selector sent to instance 0x71cae70
2013-03-30 21:17:31.264 thefyp[14311:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CViewController setCurrentQuestion:]: unrecognized selector sent to instance 0x71cae70'
我知道问题是 A 发现很难区分 segue 并试图发送有关当前问题的 C 数据,而我只想在 A 完成显示所有问题并且没有数据传输时显示 C A 与 B 接轨。B & C 也是 A 的子类。任何帮助将不胜感激