简体   繁体   English

-[__ NSDictionaryI setObject:forKey:]:无法识别的选择器已发送到实例0x91da0f0

[英]-[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x91da0f0

when i set the value in nsmutabledictionary then given error show in image below.... 当我在nsmutabledictionary中设置值时,给定的错误显示在下图中....

在此处输入图片说明

here my code for setvalue in nsmutabledictionary 这是我在nsmutabledictionary中的setvalue代码

NSMutableArray *countArray=[[NSMutableArray alloc] init];
for (int i=0;i<artistName.count;i++)
{
    int count=0;
    NSMutableDictionary *dir1=[artistName objectAtIndex:i];
    NSString *artist1=[dir1 objectForKey:@"SONG_ARTIST"];

    for (int j=0;j<CurrentPlayingSong.count;j++)
    {
        NSDictionary *dir2=[CurrentPlayingSong objectAtIndex:j];
        NSString *artist2=[dir2 objectForKey:@"SONG_ARTIST"];

        if ([artist2 isEqualToString:artist1])
        {
            count++;
        }
    }

    NSString *Size=[[NSString alloc] initWithFormat:@"%d",count];
    [dir1 setObject:Size forKey:@"SIZE"];

    [countArray addObject:dir1];
}
return countArray;

this NSMutableDictionary *dir1=[artistName objectAtIndex:i]; NSMutableDictionary *dir1=[artistName objectAtIndex:i]; returns a NSDictionary object which turns your dir1 to the same type. 返回一个NSDictionary对象,该对象将dir1转换为相同的类型。

best way is to do something like this: 最好的方法是做这样的事情:

NSMutableDictionary *dir1=[NSMutableDictionary dictionaryWithDictionary:[artistName objectAtIndex:i]];

or 要么

NSMutableDictionary *dir1 = [artistName[i] mutableCopy];

This will ensure that dir1 will always be NSMutableDictionary. 这将确保dir1始终为NSMutableDictionary。

hope this helps 希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [__NSDictionaryI setObject:forKey:]:无法识别的选择器已发送到实例 - [__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance [NSDictionaryI setObject:forKey:]: 无法识别的选择器发送到实例 - [NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance -[__ NSDictionaryI arrayForKey:]:无法识别的选择器已发送到实例 - -[__NSDictionaryI arrayForKey:]: unrecognized selector sent to instance -[__ NSDictionaryI rangeOfString:options:]:无法识别的选择器已发送到实例 - -[__NSDictionaryI rangeOfString:options:]: unrecognized selector sent to instance [__NSDictionaryI个字节]:无法识别的选择器已发送到实例 - [__NSDictionaryI bytes]: unrecognized selector sent to instance __NSDictionaryI setObject:forKey:崩溃 - __NSDictionaryI setObject:forKey: Crash - [UITableViewController setManagedObjectContext:]:无法识别的选择器发送到实例0x7490da0' - -[UITableViewController setManagedObjectContext:]: unrecognized selector sent to instance 0x7490da0' &#39; - [__ NSDictionaryI length]:无法识别的选择器发送到实例&#39; - 试图找出原因 - '-[__NSDictionaryI length]: unrecognized selector sent to instance' - trying to figure out why 无法识别的选择器已发送到实例0x7f9ccc8886a0 - unrecognized selector sent to instance 0x7f9ccc8886a0 无法识别的选择器发送到实例 0x7fa2f8636ae0 - unrecognized selector sent to instance 0x7fa2f8636ae0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM