我試圖把與名爲「持續時間」的鍵相關聯的值放入UILabel
,但我在UILabel
中得到一個空白或「(null)」結果。NSString從NSDictionary鍵進入UILabel時遇到困難
我NSDictionary
對象,其鍵似乎被記錄爲全面的數據和密鑰我想我要的,因爲這樣的:
這個RecordingsStats的內容是:
{
"12:48:25 AM, April 25" = {
FILEPATH = "/Users/brian/Library/Application Support/iPhone Simulator/3.1.3/Applications/97256A91-FC47-4353-AD01-15CD494060DD/Documents/12:48:25 AM, April 25.aif";
duration = "00:04";
applesCountString = 0;
.. 。等等。
這裏就是我試圖把NSString
到UILabel
代碼:
cell.durationLabel.text = [NSString stringWithFormat:@"%@",[thisRecordingsStats objectForKey:@"duration"]];
我也試過這些排列:
和我我也試過這種基於標籤的方法:
label = (UILabel *)[cell viewWithTag:8];
label.text = [[thisRecordingsStats objectForKey:@"duration"] objectAtIndex:1];
和:
UILabel *label;
label = (UILabel *)[cell viewWithTag:8];
label.text = [NSString stringWithFormat:@"%@",[[thisRecordingsStats objectForKey:@"duration"] objectAtIndex:1]];
我也試着從創建密鑰的配對值的字符串,看看使用太一「(空)」值或空白。
我錯過了什麼?我認爲這是與字符串格式的東西。感謝您的期待!
你在哪裏設置文本設置就行了斷點。在控制檯的gdb提示符處,輸入po [thisRecordingsStats objectForKey:@「duration」]。你看到了什麼? – cduhn 2010-04-25 18:09:06
當我輸入: PO [thisRecordingsStats objectForKey:@ 「持續時間」] 或嘗試下面的建議答案時: PO [統計objectForKey:@ 「持續時間」] 我看到:在地址0x0 – Brian 2010-04-25 19:16:15
卻不能訪問內存現在我在那裏看到我的絃樂。謝謝你,雖然下面的答案試圖嵌套一個動態的關鍵是截斷的文件名日期鍵... – Brian 2010-04-25 19:33:03