gpt4 book ai didi

ios - 程序因未知原因崩溃

转载 作者:行者123 更新时间:2023-12-01 21:51:46 26 4
gpt4 key购买 nike

我不明白为什么会发生这个错误。我已经坚持了好几天了。我有一个名为 ADViewController 的 VC,它显示 plist 文件中的问题。它有自己的类,并且是 ViewController 而不是 UIViewController 的子类(这可能值得一提)。我很难执行 Segue“LevelCleared”,它是它自己的类 ClearedAd1ViewController。如果这是一个愚蠢的问题,我深表歉意,但我自己无法弄清楚。这是ADViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];
rootArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Addition1" ofType:@"plist"]];
currentQuestion = -1;
[self showNextQuestion];

}
-(void) showNextQuestion{
currentQuestion++;
if (currentQuestion <= 2) {

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:@"LevelCleared" sender:nil];

}
}

我会将 NSLog 消息写入控制台,但不会执行 Segue。当它到达数组中的第三项时,我想执行转场,但我不断收到此错误

 2013-03-30 16:37:15.912 thefyp[1268:c07] End of Array 
2013-03-30 16:37:15.915 thefyp[1268:c07] -[ClearedAd1ViewController setCurrentQuestion:]: unrecognized selector sent to instance 0x757fcd0
2013-03-30 16:37:15.916 thefyp[1268:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ClearedAd1ViewController setCurrentQuestion:]: unrecognized selector sent to instance 0x757fcd0'
***First throw call stack:
(0x1cb8012 0x10f5e7e 0x1d434bd 0x1ca7bbc 0x1ca794e 0x834b 0x481b87 0x11bdd2 0x8f87 0x9050 0x1109705 0x3d2c0 0x3d258 0xfe021 0xfe57f 0xfd6e8 0x6ccef 0x6cf02 0x4ad4a 0x3c698 0x1c13df9 0x1c13ad0 0x1c2dbf5 0x1c2d962 0x1c5ebb6 0x1c5df44 0x1c5de1b 0x1c127e3 0x1c12668 0x39ffc 0x2a8d 0x29b5 0x1)
libc++abi.dylib: terminate called throwing an exception

(lldb)

最佳答案

我认为你非常困惑,我认为你想说的是 ADViewController 是 UIView 的子类而不是 ViewController 类。在这种情况下

[self performSegueWithIdentifier:@"LevelCleared" sender:nil];

无法调用,因为它是 View Controller 方法而不是 UIView 方法。这就是为什么错误说选择器已被识别。

因此,您需要在 UIView Controller 中实现代码来解决此问题。

关于ios - 程序因未知原因崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15721092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com