我想以编程方式创建一个字典,将数据提供给我的 UITableView,但我很难使用它。我想创建一个类似于此属性列表(图片) http://3.bp.blogspot.com/_ixq8Dp4ESMo/Sc-yvL3FIGI/AAAAAAAAAHY/gsNZ9Qn5CWA/s1600-h/ItemFour.jpg给予或拿走一些物品。
我看过“属性列表编程指南:以编程方式创建属性列表” http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/CreatePropListProgram/CreatePropListProgram.html我自己想出了一个小样本:
//keys
NSArray *Childs = [NSArray arrayWithObjects:@"testerbet", nil];
NSArray *Children = [NSArray arrayWithObjects:@"Children", nil];
NSArray *Keys = [NSArray arrayWithObjects:@"Rows", nil];
NSArray *Title = [NSArray arrayWithObjects:@"Title", nil];
//strings
NSString *Titles = @"mmm training";
//dictionary
NSDictionary *item1 = [NSDictionary dictionaryWithObject:Childs, Titles forKey:Children , Title];
NSDictionary *item2 = [NSDictionary dictionaryWithObject:Childs, Titles forKey:Children , Title];
NSDictionary *item3 = [NSDictionary dictionaryWithObject:Childs, Titles forKey:Children , Title];
NSArray *Rows = [NSArray arrayWithObjects: item1, item2, item3, nil];
NSDictionary *Root = [NSDictionary dictionaryWithObject:Rows forKey:Keys];
// NSDictionary *tempDict = [[NSDictionary alloc] //initWithContentsOfFile:DataPath];
NSDictionary *tempDict = [[NSDictionary alloc] initWithDictionary: Root];
我正在尝试将这些层次结构数据用于我的表视图。
所以我想知道如何以编程方式创建我的属性列表(字典),以便我可以用我自己的数组填充它。
我对 iPhone 开发还是个新手,所以请耐心等待。 ;)