2017-05-30 66 views
-5
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" 

我想在陣列

關鍵open_now值這是我的NSArray的輸出。它包含一些字符串爲Not Available,它包含一些以{「open_now」= 1開頭的NSDictionary; 「weekday_text」=(); }。我想只有open_now的值。我不知道如何在新的NSArray中獲得open_now的價值。請任何人幫助我。

+0

重新格式化帖子,在文本前插入8個空格以進行縮進。 – SPlatten

回答

0

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

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

我已經嘗試過#Subrat Padhi同樣不起作用 –

+0

請讓我們知道你的代碼示例,可以幫助我理解問題的出處。 –

0

您可以使用valueForKeyPath的NSArray的方法來獲得特定的鍵的值。

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

它不工作。在我的數組中有一些字符串和一些NSDictionary隨機存儲。所以我只想要關鍵「open_now」的價值。它給出的例外: - 由於未捕獲的異常'NSUnknownKeyException',原因:'[<__ NSCFConstantString 0x10ba54d20> valueForUndefinedKey:]:該類不是符合密鑰open_now密鑰的密鑰值。 –