Objective c 线程1:信号sigabrt错误

Objective c 线程1:信号sigabrt错误,objective-c,Objective C,为什么我在NSLog(@“%@”,number[I])上得到线程错误行 #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSMutableArray *numbers = [NSMutableArray array]; int i; //Create an arry with the number 0-9

为什么我在
NSLog(@“%@”,number[I])上得到线程错误

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {

    NSMutableArray *numbers = [NSMutableArray array];
    int i;

    //Create an arry with the number 0-9

    for (i = 0; i < 10; ++i) {
        numbers[i] = @(i);

        //Sequence through the array and display the values

        for (i = 0; i < 10; ++i) {
            NSLog(@"%@", numbers[i]);

            //Look how NSLog can display it with a singe %@ format

            NSLog(@"====== Using a single NSLog");
            NSLog(@"%@", numbers);
        }
    }

}
return 0;
}
#导入
int main(int argc,const char*argv[]
{
@自动释放池{
NSMutableArray*数字=[NSMutableArray];
int i;
//创建一个编号为0-9的arry
对于(i=0;i<10;++i){
数字[i]=@(i);
//对数组进行排序并显示值
对于(i=0;i<10;++i){
NSLog(@“%@”,编号[i]);
//看看NSLog如何以单%@格式显示它
NSLog(@“=======使用单个NSLog”);
NSLog(@“%@”,数字);
}
}
}
返回0;
}

您收到了一个异常,因为嵌套了两个
for
循环,而内部循环正试图迭代
numbers
数组中的十个值,但在外部循环中填充数组之前尝试这样做

我想您不希望这些
for
循环嵌套:

NSMutableArray *numbers = [NSMutableArray array];
int i;

//Create an array with the number 0-9

for (i = 0; i < 10; ++i)
    numbers[i] = @(i);

//Sequence through the array and display the values

for (i = 0; i < 10; ++i) 
    NSLog(@"%@", numbers[i]);

//Look how NSLog can display it with a single %@ format

NSLog(@"====== Using a single NSLog");
NSLog(@"%@", numbers);
NSMutableArray*numbers=[NSMutableArray];
int i;
//创建一个数字为0-9的数组
对于(i=0;i<10;++i)
数字[i]=@(i);
//对数组进行排序并显示值
对于(i=0;i<10;++i)
NSLog(@“%@”,编号[i]);
//看看NSLog如何以单个%@格式显示它
NSLog(@“=======使用单个NSLog”);
NSLog(@“%@”,数字);

这当然不是一个Xcode问题。此外,您可以阅读(整个)异常消息——问题是您正在访问超出范围的阵列。如果您原谅我的观察,虽然我很高兴您得到了问题的答案,但是,将来,如果您发布有关错误或崩溃的问题,确保发布完整的错误消息和堆栈跟踪。看见