gpt4 book ai didi

objective-c - 如何在 ios 中定义 2x2 数组?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:19 24 4
gpt4 key购买 nike

如何在 ios 中定义 2x2 或 3X.. 数组?像这样

[name=john , age=21 , num=1]
[name=max , age=25 , num=2]
[name=petter , age=22 , num=3]

有列在 NSMutableArray 中,您只能添加带有对象的行;我想要这个数组[][]

最佳答案

看看你的例子,我不会用数组来做,或者不仅仅是数组。我有一组字典或一组具有属性名称、年龄和数字的自定义对象。使用字典:

NSArray* theArray = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"john", @"name",
[NSNumber numberWithInt: 21], @"age",
[NSNumber numberWithInt: 1], @"num",
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"max", @"name",
[NSNumber numberWithInt: 25], @"age",
[NSNumber numberWithInt: 2], @"num",
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"petter", @"name",
[NSNumber numberWithInt: 22], @"age",
[NSNumber numberWithInt: 3], @"num",
nil],
nil];

关于objective-c - 如何在 ios 中定义 2x2 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5351361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com