为什么我的数组搜索 return 0 而不是 1?
Why does my array search return 0 and not 1?
我正在做一个非常简单的 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 的调试输出时,它 returns 0 而我预期它是 1,这是为什么?
2017-04-07 11:20:27.644139 NWMobileTill[2134:701297] isCashTender = 0
tenderRows
只包含一个对象,它不是字符串 "Cash"
;这是一个 Tender 实体。
Tender 实体可能有一个 type
属性,其值为 "Cash"
,但这不是你问的问题(containsObject:
)。
我正在做一个非常简单的 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 的调试输出时,它 returns 0 而我预期它是 1,这是为什么?
2017-04-07 11:20:27.644139 NWMobileTill[2134:701297] isCashTender = 0
tenderRows
只包含一个对象,它不是字符串 "Cash"
;这是一个 Tender 实体。
Tender 实体可能有一个 type
属性,其值为 "Cash"
,但这不是你问的问题(containsObject:
)。