【问题标题】:ios NSArray get all index between 2 indexios NSArray 获取 2 个索引之间的所有索引
【发布时间】:2014-04-05 22:07:04
【问题描述】:

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

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

我想从每个人那里得到名字,有什么想法吗?

【问题讨论】:

  • 你能把数组结构描述得更清楚一点吗?
  • 请发布您的代码;你的问题没有多大意义。
  • 看起来NSDictionarys数组应该是一个更好的结构。数组是如何创建的?

标签: ios objective-c nsarray


【解决方案1】:

你可以试试这个

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"];

【讨论】:

    猜你喜欢
    • 2011-11-15
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2011-02-22
    • 1970-01-01
    • 2012-05-23
    相关资源
    最近更新 更多