嵌套的NSDictionaries实现

时间:2011-12-15 04:56:44

标签: iphone objective-c ios xcode

我正在研究将plist与字典实现存储为的应用程序:

Name    abc
Address def
ID      123

以上是轻松实现的,但现在我想在第二个帐户条目中追加并实施:

First
 Name    abc
 Address def
 ID      123
Second
 Name    abc
 Address def
 ID      123

...

任何人都可以帮助

2 个答案:

答案 0 :(得分:2)

您是否只是在寻找如何创建字典数组?

NSMutableArray *array = [NSMutableArray array];

NSDictionary *first = [NSDictionary dictionaryWithObjectsAndKeys:@"abc",@"Name",@"def",@"Address",[NSNumber numberWithInt:123],@"ID", nil];

NSDictionary *second = [NSDictionary dictionaryWithObjectsAndKeys:@"abc",@"Name",@"def",@"Address",[NSNumber numberWithInt:123],@"ID", nil];

[array addObject:first];
[array addObject:second];
// [array addObject:another] and so on.

答案 1 :(得分:1)

将其设为NSMutableArray,其中包含NSDictionary s