我有两个 xml 文件,我正确地解析了它们,一切都在我的日志中,我想将我的按钮标签连接到我的 xml 数组,但我有这个错误
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -
[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x1c9b012 0x10d8e7e 0x1c3d0b4 0x30b0 0x101817 0x101882 0x50a25 0x50dbf 0x50f55 0x59f67
0x1dfcc 0x1efab 0x30315 0x3124b 0x22cf8 0x1bf6df9 0x1c1ef3f 0x1c1e96f 0x1c41734
0x1c40f44 0x1c40e1b 0x1e7da 0x2065c 0x26dd 0x2605)
libc++abi.dylib: terminate called throwing an exception
这是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
pLabel.textColor = [UIColor blackColor];
Presentation *p1 = [appDelegate.presentationArray objectAtIndex:0];
NSLog(@"p1 %@", p1);
pLabel.text = p1.pLabel;
p2Label.textColor = [UIColor blackColor];
//I have error in this line objectAtIndex:1
Presentation *p2 = [appDelegate.presentationArray objectAtIndex:1];
NSLog(@"p2 %@", p2);
p2Label.text = p2.pLabel;
[yBtn setTag:0];
[dBtn setTag:1];
}
这是 appDelega 中的部分解析:http: //pastebin.com/SygRZAGj
这是 XMLParser 类: http: //pastebin.com/yuFNnFB7
你能帮我实现这个吗,我怎样才能将所有文件放在同一个数组中,我的问题是因为空数组但是我应该如何以及我应该如何解决这个问题
提前致谢!
编辑:
我只想初始化一次,然后在同一个数组中一个接一个地添加每个演示对象,我该怎么做