2011-12-15 46 views
-2

我的应用程序的工作为:嵌套NSDictionaries与字典实现存储的plist执行

Name abc 
Address def 
ID  123 

以上是很容易实现,但现在我要追加和第二帐户条目实现:

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

...

任何人可以帮助好心

+0

NSDictionary可以包含任何其他Objective-C对象,包括NSDictionary。 – 2011-12-15 04:59:21

回答

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

让它作为NSMutableArray其中包含NSDictionary s

+0

我已编辑好心再看看解决方案,并建议我 – 2011-12-15 06:44:12