面对奇怪的问题,当我尝试拨打下一课时,我的应用程序在 IOS6 中崩溃只有当我在IOS5和IOS7中测试我的应用程序时才能正常工作.Crash屏幕截图
当我用谷歌搜索这个问题时,我得到了以下Solutions但是单一的一个并没有帮助我解决我的问题。
这是我的代码,它是Crashing
-(IBAction)notesMethod{
NotesClass *notes = [[NotesClass alloc] initWithNibName:@"NotesClass" bundle:nil];
[self presentViewController:notes animated:YES completion:nil];
}
- (void)viewDidLoad
{
NSArray *arrTemp1 = [[NSArray alloc]initWithObjects:@"Single Event Probability", @"Mutiple Event Probability",@"Permutation", @"Combination",nil];
NSArray *arrTemp2 = [[NSArray alloc]initWithObjects:@"Bionomial Distribution",@"Negativ Bionomial Distribution",@"Hypergeometric Distribution",@"Comulative Hypergeometric Distribution",@"Poission Distribution",@"Multinomial Distribution",nil];
NSArray *arrTemp3 = [[NSArray alloc]initWithObjects:@"Uinform Distribution",@"Exponential Distribution",@"Gamma Distribution",@"Gamma Function", @"Beta Distribution", @"Beta Function", @"Standard Normal Distribution",@"PDF of Normal Distribution", @"Z-Table", nil];
NSDictionary *temp =[[NSDictionary alloc]initWithObjectsAndKeys:arrTemp2,@"Discreet Probability Distribution",arrTemp3,@"Continuouse Probability Distribution",arrTemp1,@"Probability",nil];
}
在呈现下一个视图之前,我的应用程序会崩溃。 当我读到关于xib问题的线程1:信号SIGABRT 时,我确信我的xib文件没有问题。
崩溃输出
StatisticCal[3091:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDictionary initWithObjects:forKeys:]: count of objects (0) differs from count of keys (3)'
*** First throw call stack:
(0x1886012 0x1439e7e 0x1891737 0xe456d6 0xe6af79 0xe6c507 0xe43c85 0xe6af79 0xe69e97 0xeb67c1 0xf688d3 0xe6af79 0xe69e97 0x4b78c4 0xe6af79 0xe69e97 0x59d648 0xe6af79 0xe6c507 0xe43c85 0xe6af79 0xe69e97 0x59caa3 0x461e37 0x462418 0x462648 0x462882 0x46e235 0x66d3d2 0x46b4f3 0x46b777 0x184cb 0x144d705 0x384920 0x5c0b24 0x144d705 0x384920 0x3848b8 0x445671 0x445bcf 0x444d38 0x3b433f 0x3b4552 0x3923aa 0x383cf8 0x16d0df9 0x16d0ad0 0x17fbbf5 0x17fb962 0x182cbb6 0x182bf44 0x182be1b 0x16cf7e3 0x16cf668 0x38165c 0x6fbc 0x6f55) libc ++ abi.dylib:terminate调用抛出异常
任何建议都会受到赞赏。谢谢
答案 0 :(得分:1)
错误讯息:
StatisticCal [3091:c07] **因未捕获的异常而终止应用 'NSInvalidArgumentException',原因:'** - [NSDictionary initWithObjects:forKeys:]:对象计数(0)与计数不同 键(3)'
创建字典时的对象和键的数量不同。这应该可以帮助您找到错误。
这也可能是您访问已发布对象的内存问题。释放的对象不会立即被覆盖,并且当重用发生时可以是随机的,这可以解释为什么有时它可以工作,有时不会。
添加异常断点,当它被命中时继续获取更多信息。要在Navigator选择断点中添加断点选择断点,请单击Xcode窗口左下角的“+”,选择“Add Exception Breakpoint”。
顺便说一下,这是一种格式化数据的好方法(只是在这里播放):
NSArray *arrTemp1 = @[@"Single Event Probability",
@"Mutiple Event Probability",
@"Permutation",
@"Combination"];
NSArray *arrTemp2 = @[@"Bionomial Distribution",
@"Negativ Bionomial Distribution",
@"Hypergeometric Distribution",
@"Comulative Hypergeometric Distribution",
@"Poission Distribution",
@"Multinomial Distribution"];
NSArray *arrTemp3 = @[@"Uinform Distribution",
@"Exponential Distribution",
@"Gamma Distribution",
@"Gamma Function",
@"Beta Distribution",
@"Beta Function",
@"Standard Normal Distribution",
@"PDF of Normal Distribution",
@"Z-Table"];
NSDictionary *temp = @{@"Probability" : arrTemp1,
@"Discreet Probability Distribution" : arrTemp2,
@"Continuouse Probability Distribution" : arrTemp3};