2009-12-28 122 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