2011-05-04 95 views
0

嘿,夥計們,所以我有這樣的代碼:問題檢索字符串從NSDictionary的

SJLog(@"dict: %@",dict); 

,打印這本字典:

2011-05-04 02:37:51.537 Parking[14458:207] dict: { 
    "A_SPACES" = 0; 
    "DP_SPACES" = 7; 
    "LOT_DESC" = "West of the Maddy Lab off of West Health Science Dr."; 
    "LOT_ID" = 44; 
    "LOT_NAME" = LOT57; 
    "L_SPACES" = 0; 
    "MC_SPACES" = 8; 
    "VISITOR_SPACES" = 263; 
    "permits_accepted" =  { 
     A = 1; 
     C = 1; 
     L = 0; 
    }; 
} 

,我試圖通過下面的代碼檢索LOT_DESC值:

SJLog(@"lot description from dict: %@ ",[dict objectForKey:@"@LOT_DESC"]); 

但我得到這個:

2011-05-04 02:37:51.537 Parking[14458:207] lot description from dict: (null) 

如果我使用[dict valueForKey:@"@LOT_DESC"]我得到以下錯誤:

2011-05-04 02:44:28.148 Parking[14505:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFDictionary 0x58c8660> valueForUndefinedKey:]: this class is not key value coding-compliant for the key LOT_DESC.' 

通過valueForKey訪問字典中的所有數值正常工作。所以,我不知道哪裏出了問題,真的會喜歡一些建議。提前致謝!

回答

2

試試這個

SJLog(@"lot description from dict: %@ ",[dict objectForKey:@"LOT_DESC"]); 
+0

主要捂臉......我覺得A F ***現在荷蘭國際集團蠢蛋。謝謝。 – Stunner 2011-05-04 10:26:13