来自plist词典KEYS,iOS的UITableView

Wri*_*sCS 0 key plist jailbreak nsarray ios

我试图在越狱的iPhone上的iTunes目录中获取自定义铃声的名称.我可以成功列出自定义铃声,但它们显示为HWYH1.m4r,这是iTunes重命名文件的方式,但我知道这是一种解密歌曲实际名称的方法.

    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];
Run Code Online (Sandbox Code Playgroud)

dictionary 正在回归:

"YBRZ.m4r" =     
{
    GUID = 17A52A505A42D076;
    Name = "Wild West";
    "Total Time" = 5037;
};
Run Code Online (Sandbox Code Playgroud)

cell.textLabel.text 正在回归: name: (null)

Ed *_*rty 5

NSMutableArray *customRingtone = [[dictionary objectForKey:@"Name"] objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)

这条线完全错了.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;
Run Code Online (Sandbox Code Playgroud)

另请注意,我没有使用NSMutableDictionarys.如果你不需要字典是可变的,你可能应该有一个可变字典.