字符串值在目标C中始终显示为nil

Aru*_*run 42 objective-c ios

我已升级到Xcode 5.0.当我在调试模式下运行应用程序并尝试NSString在控制台中打印一个 值时,它会给我以下错误.有任何想法吗?

error: warning: couldn't get cmd pointer (substituting NULL): Couldn't load '_cmd' because its value couldn't be evaluated
Couldn't materialize struct: the variable 'stringValue' has no location, it may have been optimized out
Errored out in Execute, couldn't PrepareToExecuteJITExpression
Run Code Online (Sandbox Code Playgroud)

这是代码:

NSString *stringValue = [[self.responseArray objectAtIndex:i] valueForKey:@"merchant_name"]; 
Run Code Online (Sandbox Code Playgroud)

abb*_*ood 80

原因在错误消息中说明:它可能已经过优化 ..这意味着您正在以优化的方式编译和运行代码.

你必须将编译器优化级别从更改Fastest,Smallestnone:

  • 转到目标构建设置
  • 搜索优化级别
  • 将其更改为none(无论您处于何种模式,即调试,分发或发布)
  • 利润

为您的项目设置执行相同的操作

  • 我遇到了同样的问题.更改编译器优化级别对我来说不起作用.只有在尝试调试属于我的应用程序所使用的库的代码时才会出现此问题(该库已包含在我的项目中并由我自己编译).我没有运气,更改了库项目,库目标,主应用程序项目和主应用程序目标中的优化设置. (7认同)
  • @TapasPal自然会......你想要为你的生产计划提供最全面的优化水平 (2认同)

Mer*_*ial 38

确保您处于调试模式.Go Edit Scheme > Build Configuration > Debug


小智 9

您可能正在尝试在"发布方案"中进行调试.转到"产品/方案/编辑方案",然后在左侧面板中选择"运行".然后将构建配置更改为"debug".