【问题标题】:runtime error ns invalid arguement exception运行时错误与无效参数异常
【发布时间】:2013-08-09 20:54:20
【问题描述】:

我是一个使用 Objective C 进行 IOS 编程的新手。我没有太多经验,希望得到一些帮助。

这是描述错误的输出:2013-08-08 17:48:47.957 multMachine[57549:c07] -[ViewController play:]: unrecognized selector sent to instance 0x7578870 2013-08-08 17:48:47.959 multMachine[57549:c07] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[ViewController 播放:]:无法识别的选择器发送到实例 0x7578870 '

//  ViewController.h
//  multMachine
//
//  Created by Danny Takeuchi on 8/7/13.
//  Copyright (c) 2013 Danny Takeuchi. All rights reserved.
//

#import <UIKit/UIKit.h>
NSString *questionList[100];
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *playButton;
@property (weak, nonatomic) IBOutlet UILabel *question;
@property (weak, nonatomic) IBOutlet UITextField *answer;
- (IBAction)prepareQuestion:(id)sender;
- (IBAction)process:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *checkAnswer;

@end







//
//  ViewController.m
//  multMachine
//
//  Created by Danny Takeuchi on 8/7/13.
//  Copyright (c) 2013 Danny Takeuchi. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)process:(id)sender {

}
- (IBAction)prepareQuestion:(id)sender {
    int z=0;
    while(z<=100){
        for(int x=1;x<=10;x++){
            for(int y=1;y<=10;y++){
                questionList[z]=[[[NSString stringWithFormat:@"%d",x] stringByAppendingString:@"*"] stringByAppendingString:[NSString stringWithFormat:@"%d",y]];
            }
        }
    }
    [_question setText:questionList[random()%100]];
}
@end

【问题讨论】:

    标签: objective-c runtime runtime-error


    【解决方案1】:

    您什么时候收到此错误?是按播放键的时候吗?您是否创建并连接了 -(IBAction)play:(id)sender; 并将其删除?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-12
      • 1970-01-01
      • 2013-12-26
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      • 2011-07-17
      • 2014-06-27
      相关资源
      最近更新 更多