Ios 以下代码中的EXC_BAD_访问异常

Ios 以下代码中的EXC_BAD_访问异常,ios,memory-management,nsmutablearray,automatic-ref-counting,Ios,Memory Management,Nsmutablearray,Automatic Ref Counting,我真的不明白为什么上面的代码会抛出异常 因为在内部可变数组中,您分配了两个不同的对象。一个是Obj-C字符串@,另一个是C字符串 所以我改变了你的代码和它的工作方式 NSMutableArray *quesArrayForPar0 = [[NSMutableArray alloc] initWithObjects: [[NSMutableArray alloc] initWithObjects:@"We have a clearly stated vision for the next

我真的不明白为什么上面的代码会抛出异常

因为在内部可变数组中,您分配了两个不同的对象。一个是Obj-C字符串@,另一个是C字符串

所以我改变了你的代码和它的工作方式

    NSMutableArray *quesArrayForPar0 = [[NSMutableArray alloc] initWithObjects:

[[NSMutableArray alloc] initWithObjects:@"We have a clearly stated vision for the next 5 years.", "-1", nil], 

[[NSMutableArray alloc] initWithObjects:@"Our organization has clearly established strategy to achieve the vision.", "-1", nil],

 [[NSMutableArray alloc] initWithObjects:@"This strategy is implemented uniformly and effectively throughout our organization.", "-1", nil], 

[[NSMutableArray alloc] initWithObjects:@"We are progressing as per our plan to realize this vision within the envisage time horizon.", "-1", nil]

, nil];

你的密码里真的有-1吗?哦。。忘记在-1.之前加上@。。一个非常愚蠢的错误。也可能是雷文德里希文章的副本。@Shradha如果我的答案对你有帮助,请接受。一个是Obj-C字符串,另一个是C字符串
NSMutableArray *quesArrayForPar0 = [[NSMutableArray alloc] initWithObjects:
                                    [[NSMutableArray alloc] initWithObjects:@"We have a clearly stated vision for the next 5 years.", @"-1", nil],
                                    [[NSMutableArray alloc] initWithObjects:@"Our organization has clearly established strategy to achieve the vision.", @"-1", nil],
                                    [[NSMutableArray alloc] initWithObjects:@"This strategy is implemented uniformly and effectively throughout our organization.", @"-1", nil],
                                    [[NSMutableArray alloc] initWithObjects:@"We are progressing as per our plan to realize this vision within the envisage time horizon.", @"-1", nil]
                                    , nil];