检查 NSMutableArray 中的值
我有一个 NSMutableArray(contactsArray) ,其内容如下。
{({ContactID = ""; RecordID = 45; Number = "";},
{ContactID = 134;RecordID = 47;Number = PNAPYOEMZH;})}
我有一个自变量说x。我需要检查 x 是否等于数组中的 ContactID
I have an NSMutableArray(contactsArray) with contents as below.
{({ContactID = ""; RecordID = 45; Number = "";},
{ContactID = 134;RecordID = 47;Number = PNAPYOEMZH;})}
I have an independent variable say x. I need to check whether x is equal to the ContactID in the array
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 isEqual 来检查数组数据之间的内容,尝试一下
这里发生的情况是 if 语句将数组内的对象与索引或行“theIndex”
希望 中的数据中的“ContactId”和“RecordID”的值进行比较此帮助
编辑:由于您将问题编辑为具有变量 X,因此您可以将第二个参数比较器更改为 [NSNumber numberWithInt:x]
如果您的 X 是 String 类型,则应该使用 .intValue
you can use isEqual to check things between array data, try this
what happened here is the if sentences is comparing the object inside your array with the value of "ContactId" with "RecordID" at the data in the index or row "theIndex"
hope this help
edit : since you edited the question into having a variable X, you can just change the second parameter comparer to [NSNumber numberWithInt:x]
if your X is a String type, you should use .intValue
您可以执行以下操作:
或将谓词更改为:
You could do something like this:
or change the predicate to: