objectForKeyedSubscript:在iOS 5.1上崩溃 [英] objectForKeyedSubscript: crash on iOS 5.1

查看:228
本文介绍了objectForKeyedSubscript:在iOS 5.1上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一些执行[NSDictionary objectForKeyedSubscript:]的代码,它在iOS 5上崩溃,但不在iOS 6上崩溃。我正在使用xcode 4.5.2并针对iOS 6.0 SDK进行编译。

I'm running some code that does a [NSDictionary objectForKeyedSubscript:] and it's crashing on iOS 5, but not iOS 6. I am using xcode 4.5.2 and compiling against the iOS 6.0 SDK.

我认为这可以在iOS 5上运行,因为它只是一个编译器功能?我错了吗?我可以自己编写这些函数的版本,但是我担心其他错误,因为我希望它可以工作。

I assumed that this would work on iOS 5 since it's just a compiler feature? Am I wrong about that? I can just write my own versions of those functions, but I'm worried that something else is wrong since I would expect it to work.

推荐答案

好的,我会回答我自己的问题,虽然我不完全理解为什么会失败。

OK, I'm going to answer my own questions, although I don't completely understand why it was failing.

使用 objectForKeyedSubscript:等在iOS 5中运行良好(只要它是针对iOS 6 SDK编译的)。

Using objectForKeyedSubscript: and the like works fine running in iOS 5 (as long as it was compiled against the iOS 6 SDK).

问题是我命名了一个函数 +(void)load 并且在此函数中调用 objectForKeyedSubscript:会因为该方法而导致断言没找到。

The problem was I named a function +(void)load and making objectForKeyedSubscript: calls in this function causes an assert due to the method not being found.

这是我的命名错误,因为在App完全运行之前调用了load方法。我已经更改了我的函数的名称,一切都很好。

This was an naming error on my part because the load method is called before the App is fully running. I have changed the name of my function and all is well.

我假设在完全插入NSDictionary之前调用了+ load。奇怪的是,它在iOS 6下工作,而不是iOS 5。

I assume +load is being called before something with NSDictionary is fully inited. Odd that it works under iOS 6 and just not iOS 5.

也许这不奇怪。

这篇关于objectForKeyedSubscript:在iOS 5.1上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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