本文介绍了为什么我的数组搜索返回 0 而不是 1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am doing a very simple NSArray search as follows

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

数组的调试输出告诉我现金"中有一个对象,如下所示(倒数第二个)

A debug output of the array tells me there is an object in there "Cash" as seen below (its the second to last one)

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 的调试输出时,它返回 0,而我预期它是 1,这是为什么呢?

But when I look at the debug output of my BOOL it returns 0 when I expected it to be 1, why is that?

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

推荐答案

tenderRows 只包含一个对象,而不是字符串 "Cash";这是一个 Tender 实体.

tenderRows contains just one object, and it isn't a string "Cash"; it's a Tender entity.

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

That Tender entity may have a type attribute whose value is "Cash", but that is not the question you asked (with containsObject:).

这篇关于为什么我的数组搜索返回 0 而不是 1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 04:49