【问题标题】:rangeOfString:@"fReturnValue"].location == NSNotFound method never firedrangeOfString:@"fReturnValue"].location == NSNotFound 方法从未被触发
【发布时间】:2014-01-14 04:18:58
【问题描述】:

我已经将应用提交到应用商店。所以我不能对前端代码做任何改变。但我想使用 Web 服务(后端代码)更改应用程序的功能

所以我需要在 if 条件下触发。

if (![returnValue rangeOfString:@"fReturnValue"].location == NSNotFound)
{
    returnValue = [_common getWebServiceResponseValueWithOutUnnecessary:returnValue withFieldName:@"fReturnValue"];
}

我的返回值是,

{"d":{"__type":"System.Data.DataTable","fReturnValue":"[{\"FldName\":\"PurchsOrdr\",\"TblName\":\"FCDOCHST\",\"Module\":\"Document\",\"Mandatory\":1,\"FldCaptn\":\"Purchase Order\",\"Editable\":0,\"CustomFld\":0}"}}

但是这个 if 条件永远不会为真。如果条件改变了 json 字符串,我不能这样做吗?

【问题讨论】:

  • @Bryan 的回答是正确的。此外,如果此问题对您的应用至关重要,则要么拒绝二进制文件(如果尚未发布)和/或提交具有正确客户端代码的新二进制文件。

标签: ios objective-c json


【解决方案1】:

你的代码应该是

if ([returnValue rangeOfString:@"fReturnValue"].location != NSNotFound)

但它是

if ((![returnValue rangeOfString:@"fReturnValue"].location) == NSNotFound)

类似于

NSInteger loc = [returnValue rangeOfString:@"fReturnValue"].location;
loc = !loc; // if loc is 0, it changed to 1, otherwise it changed to 0
if (loc == NSNotFound) // so this is not possible to be true

您现在应该开始制作新版本...顺便说一句,您如何在不测试的情况下提交您的应用...

【讨论】:

  • 我提交后发现了这个问题。 :(
猜你喜欢
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 2012-02-05
  • 2015-01-31
  • 1970-01-01
  • 1970-01-01
  • 2020-08-02
  • 1970-01-01
相关资源
最近更新 更多