- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在 GitHub 我有 a simple iPhone app ,它从社交网络 Mail.ru 获取用户信息(通过使用 OAuth):
它确实获取并打印了信息,但随后崩溃了。
作为 iOS 编程新手,我对下面的输出感到困惑(另请参阅 the full output at PasteBin ):
2014-01-21 21:21:10.873 oauthMailru[8228:3307] -[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290
2014-01-21 21:21:10.875 oauthMailru[8228:3307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290'
*** First throw call stack:
(
0 CoreFoundation 0x01aa65e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018298b6 objc_exception_throw + 44
2 CoreFoundation 0x01b43903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01a9690b ___forwarding___ + 1019
4 CoreFoundation 0x01a964ee _CF_forwarding_prep_0 + 14
5 oauthMailru 0x00003a62 __47-[ViewController fetchMailruWithToken:ForUser:]_block_invoke + 402
6 Foundation 0x01545695 __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 151
7 Foundation 0x014a5945 -[NSBlockOperation main] + 88
8 Foundation 0x014fe829 -[__NSOperationInternal _start:] + 671
9 Foundation 0x0147b558 -[NSOperation start] + 83
10 Foundation 0x01500af4 __NSOQSchedule_f + 62
11 libdispatch.dylib 0x021344b0 _dispatch_client_callout + 14
12 libdispatch.dylib 0x02121018 _dispatch_async_redirect_invoke + 202
13 libdispatch.dylib 0x021344b0 _dispatch_client_callout + 14
14 libdispatch.dylib 0x02122eeb _dispatch_root_queue_drain + 287
15 libdispatch.dylib 0x02123137 _dispatch_worker_thread2 + 39
16 libsystem_pthread.dylib 0x024c0dab _pthread_wqthread + 336
17 libsystem_pthread.dylib 0x024c4cce start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException
请问有人知道发生了什么以及如何解读此类崩溃吗?
我的源文件: ViewController.m ,它显示 UIWebView
然后转到 DetailViewController.m
最佳答案
您的代码认为 JSON 反序列化为对象(字典),但实际上它反序列化为包含一个对象的数组。试试这个:
NSMutableArray *topLevelArray = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dict = topLevelArray[0];
如果你想检查你得到了什么,你可以像这样使用 isKindOfClass:
:
id jso = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers error:nil];
if (jso == nil) {
// Error. You should probably have passed an NSError ** as the error
// argument so you could log it.
} else if ([jso isKindOfClass:[NSArray class]]) {
NSArray *array = jso;
// process array elements
} else if ([jso isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = jso;
// process dictionary elements
} else {
// Shouldn't happen unless you use the NSJSONReadingAllowFragments flag.
}
关于ios - [__NSArrayM objectForKeyedSubscript :]: unrecognized selector sent to instance - source code and screenshot attached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21268539/
我想知道这两者之间有什么不同 .myClass/DomElement .myotherclassinsidethatelement 和 .myClass/DomElement > .myothercl
使用 jQuery on() 版本 1.7。我通常这样绑定(bind)我的事件: $(".foo").on("click", function() { console.log("foo cli
我想找到与选择器匹配的所有元素,但如果它已经包含在匹配元素中则不查找。 $('#container').find('.child').not('.child .child'); 请注意,.child
我有一个看起来像这样的无序列表,但更广泛: Parent Category 2 Parent Category 2 Parent Category 3
这个问题在这里已经有了答案: CSS negation pseudo-class :not() for parent/ancestor elements (2 个答案) 关闭 4 年前。
我希望使用 CSS :not() 来定位 before 选择器。这可能吗? 示例: https://jsfiddle.net/uuq62b8d/ a.button:before { content
这有什么区别: $.each($('#myTable input[name="deleteItem[]"]:checked').do_something()); 还有这个: $('#myTable i
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我正在使用 UL LI 列表和 jQuery 创建一棵树。我使用了 jQuery 选择器 jQuery(li:has(ul)) 查找所有具有子节点的列表节点,然后向其添加单击事件。 jQuery(li
我真的不知道如何命名这两种方法,所以请原谅我这样调用它们。 字符串选择器 $("#myList li").eq(3); 函数选择器 $("#myList li:eq(3)"); 据我所知,他们都做同样
我有以下代码: .. 我正在使用以下 CSS 来排除具有“main-l tbl”类的表: table:not(.main-l .views-table) { .. } 我注
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicate: What is the difference between $ and jQuery 我注意到使用“jQuery(
我有许多 css 选择器和许多选择器异常,所以我使用 :not 将它们排除在外... 示例(只是一些我不需要的选择器): [class*="-dashboard-"]:not([class$="-bi
CADisplayLink 有这个方法是有道理的,但我很好奇为什么 UIScreen 也会有它。 最佳答案 文档说屏幕提供的显示链接与该屏幕相关联。但是,查看官方文档,与任何屏幕都没有明显的关系;显示
我在这里阅读了关于 toArray() 的文档,并在控制台中对其进行了测试。我找不到在选择器上调用 toArray() 和调用选择器本身之间的区别。 两种方式都得到了完全相同的结果,这是一个与选择器匹
我有一个问题,为什么这两个代码片段不同。 $('#ctl00_DDMenu1_HyperLink1') //jQuery(a#ctl00_DDMenu1_HyperLink1 Default.asp
我想通过以下方式模拟我可以在 jQuery 中实现的目标$('.someClass:not(.hidden)') 我试过下面的代码。 $crawler->filter('someClass:not(.
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我想通过以下方式模拟我可以在 jQuery 中实现的目标$('.someClass:not(.hidden)') 我试过下面的代码。 $crawler->filter('someClass:not(.
我想根据 Iterator::next 中当前枚举变体的某些属性更改枚举变体。我有两次尝试,都没有编译: enum Test { A(Vec), B, } impl Iterator
我是一名优秀的程序员,十分优秀!