Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

objective c - Why does my array search return 0 and not 1?

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: {
    amount = 10;
    authCode = nil;
    brandId = XX;
    cardEntryMode = nil;
    cardType = nil;
    createdDate = "2017-04-07T11:20:22+08:00";
    createdDateUtc = "2017-04-07T03:20:22";
    currency = EUR;
    extRefNo = "Cash-In-EUR";
    hashedPan = nil;
    inOrOut = IN;
    isSynched = 0;
    obfPan = nil;
    orderNumber = "1-20170407112015";
    status = 95;
    synchDate = nil;
    synchDateUtc = nil;
    tillId = 1;
    type = Cash;
    userName = a;
})"
)

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...