NSDictionary objectAtIndex上的SIGABRT:无法识别的选择器 [英] SIGABRT on NSDictionary objectAtIndex: unrecognized selector

查看:117
本文介绍了NSDictionary objectAtIndex上的SIGABRT:无法识别的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有一个奇怪的错误。
我有一个名为__ImageData的数组:

I'm having a weird error here. I have an array named __ImageData:

static NSArray *__ImageData = nil;
NSString *path = [[NSBundle mainBundle] pathForResource:@"ImageData" ofType:@"plist"];
NSData *plistData = [NSData dataWithContentsOfFile:path];
NSString *error; NSPropertyListFormat format;
_ImageData = [NSPropertyListSerialization propertyListFromData:plistData
                                              mutabilityOption:NSPropertyListImmutable
                                                        format:&format
                                              errorDescription:&error];

当我NSLogLog出数组的内容时,得到以下输出:

When I NSLog out the content of the array, I get this output:

2012-08-23 16:36:35.573 CAT[28814:c07] {
    "Item 0" =     {
        height = 7121;
        name = Map1;
        width = 8556;
    };
    "Item 1" =     {
        height = 7121;
        name = Map2;
        width = 8556;
    };
    "Item 2" =     {
        height = 7121;
        name = Map3;
        width = 8556;
    };
}

但是当我NSLog注销 NSLog(@% @,[__ImageData objectAtIndex:0]); ,出现此异常:

But when I NSLog out NSLog(@"%@", [__ImageData objectAtIndex:0]);, I get this exception:

2012-08-23 16:36:35.573 CAT[28814:c07] -[__NSCFDictionary objectAtIndex:]: 
unrecognized selector sent to instance 0x719d0f0
2012-08-23 16:36:35.574 CAT[28814:c07] *** Terminating app due to uncaught exception 
'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: 
unrecognized selector sent to instance 0x719d0f0'
*** First throw call stack:

等。

我有不知道如何到达此数组中的对象。似乎objectAtIndex找不到任何索引,即使index:0也找不到,即使里面有数据。有人知道如何获取它吗?
我正在使用Apple的PhotoScroller模板,并使用 CATiledLayer 。我认为整个过程有点时髦,但是每个人都说我们应该将其用于大图像。对于大图像,有人比CATiledLayer有解释或更好的主意吗? (8556 * 7121px)。

I have no idea how to reach an object in this array.. It seemes like the objectAtIndex cant find any indexes, not even index:0, even though there is data inside.. Anyone know how to get it? I am using the PhotoScroller-template from Apple, using the CATiledLayer. I think the whole thing is kinda funky, but everybody says we should use this for large images. Anyone have an explanation or a better idea than CATiledLayer for huge images? (8556*7121px).

为什么我会从NSArray收到Dictionary-error?
在执行 NSDictionary * dict = [__ImageData objectAtIndex:0] 时,我也遇到相同的异常。

And why do I get Dictionary-error from the NSArray? When doing NSDictionary *dict = [__ImageData objectAtIndex:0], I also get the same exception.

Stian。

推荐答案

_ImageData 不是数组,而是一本字典。要显示字典的第一个元素,您可以执行以下操作:

_ImageData is not an array, it is a dictionary. To display the first element of the dictionary you could do something like:

NSLog(@"%@", [_ImageData objectForKey:@"Item 0"]);

这篇关于NSDictionary objectAtIndex上的SIGABRT:无法识别的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆