xcode Objective - c - NSMutableArray 数组的数组
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6721621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:30:09 来源:igfitidea点击:
Objective - c - NSMutableArray Array of Arrays
提问by David
I am developing an iphone app and I was wondering the following:
我正在开发一个 iphone 应用程序,我想知道以下内容:
How do I initialise an NSMutableArray of NSMutableArrays to a certain size?
如何将 NSMutableArrays 的 NSMutableArray 初始化为特定大小?
Sorry for the noob question
抱歉菜鸟问题
回答by Wayne Hartman
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:5];
for (int i = 0; i < 5; i++) {
NSMutableArray *innerArray = [[NSMutableArray alloc] initWithCapacity:5];
[array addObject:innerArray];
}
回答by Nektarios
You don't set a maximum size. You just keep addObject:'ing to them
您没有设置最大尺寸。你只要保持 addObject:'ing 给他们