ios NSArray获取2索引之间的所有索引

时间:2014-04-05 22:07:04

标签: ios objective-c nsarray

我有一个包含以下内容的数组

"Dave.",
    "Dave is an awesome guy",
   Dave Lan,
"Josh.",
    "Josh is funny",
   Josh Nepy,
"Zach",
    "Zach is too lazy",
   Zach Sung

我希望得到每个人的名字,任何想法怎么做?

1 个答案:

答案 0 :(得分:0)

你可以试试这个

NSDictionary *dict1 = @{
                        @"name" : @"Dave",
                        @"desc" : @"Dave is an awesome guy",
                        @"fullName" : @"Dave Lan"
                        };

NSDictionary *dict2 = @{
                        @"name" : @"Josh",
                        @"desc" : @"Josh is funny",
                        @"fullName" : @"Josh Nepy"
                        };

NSDictionary *dict3 = @{
                        @"name" : @"Zach",
                        @"desc" : @"Zach is too lazy",
                        @"fullName" : @"Zach Sung"
                        };

NSArray *personArray = @[dict1, dict2, dict3];

//get first person des
NSString *desc = personArray[0][@"desc"];

//get the third full name
NSString *fullName = personArray[2][@"fullName"];