2009-12-28 137 views
0

我試圖在越獄的iPhone上的iTunes目錄中獲取自定義鈴聲的名稱。我可以成功列出自定義鈴聲,但他們重新顯示爲HWYH1.m4r,這是iTunes重命名文件的內容,但我知道這是解密歌曲實際名稱的一種方法。來自plist詞典的UITableView KEYS,iOS

NSMutableDictionary *custDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/iPhoneOS/private/var/mobile/Media/iTunes_Control/iTunes/Ringtones.plist"]; 
    NSMutableDictionary *dictionary = [custDict objectForKey:@"Ringtones"]; 
    NSMutableArray *customRingtone = [[dictionary objectForKey:@"Name"] objectAtIndex:indexPath.row]; 
    NSLog(@"name: %@",[customRingtone objectAtIndex:indexPath.row]); 
    cell.textLabel.text = [customRingtone objectAtIndex:indexPath.row]; 

dictionary將返回:

"YBRZ.m4r" =  
{ 
    GUID = 17A52A505A42D076; 
    Name = "Wild West"; 
    "Total Time" = 5037; 
}; 

cell.textLabel.text將返回:name: (null)

+0

那麼...你的問題是什麼? – 2009-12-29 01:39:01

+0

我怎樣才能cell.textLabel =從陣列的名字? – WrightsCS 2009-12-29 01:48:54

回答

5
NSMutableArray *customRingtone = [[dictionary objectForKey:@"Name"] objectAtIndex:indexPath.row]; 

這條線是完全錯誤的。你的對象dictionary實際上是一個NSDictionary,其鍵值等於'YBRZ.m4r'等值。您正在爲名爲「名稱」的鍵申請一個不存在的值。然後,用那個返回的對象,你發送一個方法就好像它是一個NSArray,事實並非如此。然後您希望返回NSArray。再次,我不認爲它確實如此。它應該更像這樣:

NSArray *keys = [dictionary allKeys]; 
id key = [keys objectAtIndex:indexPath.row]; 
NSDictionary *customRingtone = [dictionary objectForKey:key]; 
NSString *name = [customRingtone objectForKey:@"Name"]; 
cell.textLabel.text = name; 

另請注意,我沒有使用NSMutableDictionary s。如果你不需要字典是可變的,你可能應該有一個可變的字典。

+1

真棒,非常感謝! – WrightsCS 2009-12-29 02:19:21