gpt4 book ai didi

ios - 我无法解决这个 NSInvalidArgumentException

转载 作者:行者123 更新时间:2023-11-29 12:24:40 25 4
gpt4 key购买 nike

这是我的代码:

@interface TabRegsViewController ()
@end

@implementation TabRegsViewController

@synthesize parent;
@synthesize menu_select;

-(BOOL) shouldAutorotate {
return UIInterfaceOrientationMaskPortrait;
}

-(NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad {
NSLog(@"***************\t\t\tTab_Reg_ViewDidLoad");
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidAppear:(BOOL)animated {
//[super viewDidAppear:animated];
NSLog(@"***************\t\t\tTab_Reg_ViewDidAppear");
}

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

@end

此 UI 仅制作 Storyboard。

这个 Storyboard可以在 iPhone 5 上播放,但我的 iPhone 6 Plus 不能。

************* tab_reg_ViewDidload

terminating app to uncaught exception

'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects: count: ]: attempt to insert nil object from objects[0]'

我不知道该怎么办。

这个父类按钮事件发生后,presentViewController事件发生,页面发生变化。

iPhone 5 可以工作,但 iPhone 6 plus 会失败。

我觉得这个 TabRegsViewController viewDidLoad 没问题,但是一个异常(exception)。

我不知道如何清除这个异常。

请帮帮我。

编辑:

这个类调用方法,这个vc指针和self是nil。为什么?..

UIStoryboard *storyboard = [UIStroyboard storyboardWithName:"Main_Storyboard" bundle:nil];
TabRegsViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"TabRegsViewController"];
vc.parent = self;
[self presentViewController:vc animated:NO completion:nil];

当前异常点是

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromclass([Appdelegate class]));
}
}

错误是线程 1:信号 SIGABRTargc(整数)argv = (unsigned char ** )NULL

最佳答案

似乎 nibNameOrNil 为 nil,在下面的行中添加一个断点。并告诉我们您得到了什么。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
//Add a breakpoint overhere or NSLog the value nibNameOrNil and nibBundleOrnil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

后续回复:好的,通过阅读那些屏幕截图,我只能对您的结构有一个大概的了解。而且代码看起来不错。根据我的经验,这个错误

'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects: count: ]: attempt to insert nil object from objects[0]'

通常在您调用某些方法但缺少某些参数时发生。

你提到

This Class Call method, and this vc pointer and self is nil. why?..

你在哪个位置加个断点,发现self是nil??我需要更多代码来跟踪错误||

关于ios - 我无法解决这个 NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29596676/

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