为什么我的数组搜索返回0而不是1?

时间:2017-04-07 03:28:08

标签: objective-c nsarray

我正在做一个非常简单的NSArray搜索,如下所示

BOOL isCashTender = [_tenderRows containsObject: @"Cash"];

数组的调试输出告诉我“Cash”中有一个对象,如下所示(它是倒数第二个)

2017-04-07 11:20:27.644551 NWMobileTill[2134:701297] tenderRowsarray:(
"<Tender: 0x17009c2a0> (entity: Tender; id: 0xd0000000002c0004 <x-coredata://BE2CD993-FDED-43CE-99A3-88597A0E8046/Tender/p11> ; data: {\n    amount = 10;\n    authCode = nil;\n    brandId = XX;\n    cardEntryMode = nil;\n    cardType = nil;\n    createdDate = \"2017-04-07T11:20:22+08:00\";\n    createdDateUtc = \"2017-04-07T03:20:22\";\n    currency = EUR;\n    extRefNo = \"Cash-In-EUR\";\n    hashedPan = nil;\n    inOrOut = IN;\n    isSynched = 0;\n    obfPan = nil;\n    orderNumber = \"1-20170407112015\";\n    status = 95;\n    synchDate = nil;\n    synchDateUtc = nil;\n    tillId = 1;\n    type = Cash;\n    userName = a;\n})"
)

但是当我查看BOOL的调试输出时,当我预期它为1时它会返回0,为什么会这样?

2017-04-07 11:20:27.644139 NWMobileTill[2134:701297] isCashTender = 0

1 个答案:

答案 0 :(得分:2)

tenderRows只包含一个对象,它不是字符串"Cash";这是一个温柔的实体。

该投标实体可能有一个type属性,其值为"Cash",但这不是您提出的问题(使用containsObject:)。