我想要数组中的键open_now的值

时间:2017-05-30 09:05:37

标签: ios objective-c

Opening :- (
"Not Available",
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
"Not Available",
    {
    "open_now" = 1;
    "weekday_text" =         (
    );
},
"Not Available"

这是我的NSArray的输出。它包含一些不可用的字符串,它包含一些以{“open_now”= 1开头的NSDictionary; “weekday_text”=();我只想要open_now的值。我不知道如何在我的新NSArray中获得open_now的值。请有人帮助我。

2 个答案:

答案 0 :(得分:0)

是的,使用NSArray -valueForKey:方法。

NSArray *extracted = [sourceArray valueForKey:@"a key"];

答案 1 :(得分:0)

您可以使用 NSArray valueForKeyPath 方法获取特定密钥的值。

NSArray *aryValue = [YOUR_ARRAY valueForKeyPath:@"open_now"];