【发布时间】:2011-01-16 20:12:43
【问题描述】:
我有一个大的NSDictionary,我需要循环并创建单独的NSArrays。以下是内容:
(
{
id = {
text = "";
};
sub = {
text = " , ";
};
text = "";
"thumb_url" = {
text = "";
};
title = {
text = "2010-2011";
};
type = {
text = "title";
};
},
{
id = {
text = "76773";
};
sub = {
text = "December 13, 2010";
};
text = "";
"thumb_url" = {
text = "http://www.puc.edu/__data/assets/image/0004/76774/varieties/thumb.jpg";
};
title = {
text = "College Days - Fall 2010";
};
type = {
text = "gallery";
};
},
{
id = {
text = "";
};
sub = {
text = "";
};
text = "";
"thumb_url" = {
text = "";
};
title = {
text = "2009-2010";
};
type = {
text = "title";
};
},
{
id = {
text = "76302";
};
sub = {
text = "December 3, 2010";
};
text = "";
"thumb_url" = {
text = "http://www.puc.edu/__data/assets/image/0019/76303/varieties/thumb.jpg";
};
title = {
text = "Christmas Colloquy";
};
type = {
text = "gallery";
};
}
)
每个部分都有一个类型键,我需要检查它。当它找到title 键时,我需要将它们添加到数组中。然后将使用gallery 键的下一部分需要位于其自己的数组中,直到找到另一个title 键。然后将gallery 之后的键放入自己的数组中。
我正在使用UITableView 部分标题和内容。所以,上面的NSDictionary 应该有一个NSArray *titles; 数组和另外两个数组,每个数组都包含标题之后的画廊。
我尝试过使用for 循环,但我似乎无法做到正确。任何想法将不胜感激。
【问题讨论】:
标签: iphone objective-c ios4 nsarray nsdictionary