Cocoa:检查两个 NSArray 是否相等

发布于 2024-12-19 14:52:09 字数 139 浏览 4 评论 0原文

我有两个 NSArray 的 NSRect(使用 NSStringFromRect(NSRect) 存储)。有没有一种快速的方法来检查并查看数组中的项目是否相等或者我必须执行循环?所以数组 1 中的项目 1 = 数组 2 中的项目 1,等等。

谢谢

I have two NSArrays of NSRects (stored using NSStringFromRect(NSRect)). Is there a quick way to check and see if the items in the array are equal or will I have to do a loop? So item 1 in array 1 = item 1 in array 2, etc. etc.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断桥再见 2024-12-26 14:52:09

如果您检查 NSArray 参考,您将找到一个方便的 -isEqualToArray: 方法,它应该可以满足您的需求

If you check the NSArray Reference, you'll find a handy -isEqualToArray: method that should do just what you want

世界等同你 2024-12-26 14:52:09

来自 -[NSArray isEqualToArray:] 的文档:

将接收数组与另一个数组进行比较。如果两个数组都包含相同数量的对象,并且每个数组中给定索引处的对象满足 isEqual: 测试,则两个数组具有相同的内容。

这正是您正在寻找的。

From the documentation for -[NSArray isEqualToArray:]:

Compares the receiving array to another array. Two arrays have equal contents if they each hold the same number of objects and objects at a given index in each array satisfy the isEqual: test.

This is exactly what you are looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文